whatsApp static method

Future<bool> whatsApp({
  1. String? whatsAppNumber,
  2. String text = "",
  3. OpenMode mode = OpenMode.externalNonBrowserApplication,
})

share content to whatsapp

Implementation

static Future<bool> whatsApp(
    {String? whatsAppNumber,
    String text = "",
    OpenMode mode = OpenMode.externalNonBrowserApplication}) async {
  if (whatsAppNumber != null && whatsAppNumber.isNotEmpty) {
    try {
      return await launchUrl(
          Uri.parse(
              "https://api.whatsapp.com/send?phone=$whatsAppNumber&text=$text"),
          mode: _getLaunchMode(mode));
    } catch (e) {
      return false;
    }
  } else {
    try {
      return await launchUrl(Uri.parse("whatsapp://send?text=$text"),
          mode: _getLaunchMode(mode));
    } catch (e) {
      return false;
    }
  }
}