How to launch whatsapp and facebook messenger window from Flutter to point to a specific contact?

I found the solution.

To open whatsapp:

var whatsappUrl ="whatsapp://send?phone=$phone";
await canLaunch(whatsappUrl)? launch(whatsappUrl):print("open whatsapp app link or do a snackbar with notification that there is no whatsapp installed");

To open messenger or facebook:

First get shortened url

If your facebook profile is facebook.com/yourName facebook url would be fb.me/yourName and messenger url would be m.me/yourName

then you do launch("http://$messengerUrl");

Facebook website will automatically open the link in the app even though it goes trough URL browser. If there is no app installed, it will go to the app/play store


To open the whatsapp you can use this plugin: https://pub.dartlang.org/packages/flutter_launch

1. Add this to your package's pubspec.yaml file:

dependencies:
    flutter_launch: "^0.0.2"

2. Install it

$ flutter packages get

3. Import it

import 'package:flutter_launch/flutter_launch.dart';

4. Example:

await FlutterLaunch.launchWathsApp(phone: "5534992019999", message: "Hello");

Complete example: https://pub.dartlang.org/packages/flutter_launch#-installing-tab-