Flutter & WhatsApp

1,010 views
Skip to first unread message

Bridget Kelly O'Sheehan

unread,
Jan 5, 2022, 4:01:28 PM1/5/22
to Flutter Development (flutter-dev)
Hello All,

Can anyone recommend a flutter pub package, that can 'contact us' from within an app and open up a screen on the clients phone for Whatsapp to send a message?

I have tried a few and not really not anywhere with them?

Any help would be fab thanks!

Kindest Regards,

Bridget

Santosh Das

unread,
Jan 11, 2022, 2:13:52 AM1/11/22
to Flutter Development (flutter-dev)
Hello,
You can use url_launcher to open/send Whatsapp.


like this in a method.

if (!await launch(_url)) throw 'Could not launch $_url';

Thank You,

Murali Kumar

unread,
Jan 11, 2022, 4:05:01 AM1/11/22
to Flutter Development (flutter-dev)
Hi,
import 'package:url_launcher/url_launcher.dart';

Future openWhatsApp({required String mobileNo, required String message}) async {
  String _url = Uri.encodeFull("whatsapp://send?phone=$mobileNo&text=$message");
  //String _url = "https://api.whatsapp.com/send?phone=$mobileNo&text=${Uri.parse(message)}";
  if (await canLaunch(_url)) {
    await launch(_url);
  } else {
    throw ('Could not launch Whatsapp');
  }
}

my Playstore App
Reply all
Reply to author
Forward
0 new messages