OpenFlutter / flutter_share_me

Flutter Plugin for sharing contents to social media. You can use it share to Facebook , WhatsApp , Twitter And System Share UI. Support Url and Text.
https://github.com/lizhuoyuan
Apache License 2.0
160 stars 159 forks source link

How to directly open whatsapp? Is that possible? #33

Closed Sreejithtechno closed 3 years ago

Sreejithtechno commented 3 years ago

How to directly open whatsapp? and selected particular number to open Is that possible?

lizhuoyuan commented 3 years ago
//  https://api.whatsapp.com/send?phone=$phone&text=${URLEncoder.encode(message, "UTF-8")}
//  const url = 'whatsapp://send?phone=$phone';
const url = "https://wa.me/?text=Your Message here";
var encoded = Uri.encodeFull(url);

if (await canLaunch(encoded )) {
  await launch(encoded );
} else {
  throw 'Could not launch $url';
}