share static method

Future<bool?> share({
  1. required String phone,
  2. String? text,
  3. String? linkUrl,
  4. Package package = Package.whatsapp,
})

Shares a message or/and link url with whatsapp.

  • Text: Is the text of the message.
  • LinkUrl: Is the linkUrl to include with the message.
  • Phone: is the phone contact number to share with.

Implementation

static Future<bool?> share({
  required String phone,
  String? text,
  String? linkUrl,
  Package package = Package.whatsapp,
}) async {
  assert(phone.isNotEmpty);

  String _package;
  _package = package.index == 0 ? "com.whatsapp" : "com.whatsapp.w4b";

  final bool? success =
      await _channel.invokeMethod('share', <String, dynamic>{
    'title': ' ',
    'text': text,
    'linkUrl': linkUrl,
    'chooserTitle': ' ',
    'phone': phone,
    'package': _package,
  });

  return success;
}