shareFile static method
Shares a local file with whatsapp.
- Text: Is the
text
of the message. - FilePath: Is the List of paths which can be prefilled.
- Phone: is the
phone
contact number to share with.
Implementation
static Future<bool?> shareFile({
required List<String> filePath,
required String phone,
String? text,
Package package = Package.whatsapp,
}) async {
if (filePath.isEmpty) {
throw FlutterError('FilePath cannot be null');
} else if (phone.isEmpty) {
throw FlutterError('Phone cannot be null and with country code');
}
String _package = package.index == 0 ? "com.whatsapp" : "com.whatsapp.w4b";
final bool? success =
await _channel.invokeMethod('shareFile', <String, dynamic>{
'title': ' ',
'text': text,
'filePath': filePath,
'chooserTitle': ' ',
'phone': phone,
'package': _package,
});
return success;
}