shareToWhatsApp method
share to WhatsApp
imagePath
is local image
phoneNumber
enter phone number with counry code
For ios
If include image then text params will be ingored as there is no current way in IOS share both at the same.
Implementation
Future<String?> shareToWhatsApp(
{String msg = '',
String imagePath = '',
FileType? fileType = FileType.image}) async {
final Map<String, dynamic> arguments = <String, dynamic>{};
arguments.putIfAbsent('msg', () => msg);
arguments.putIfAbsent('url', () => imagePath);
if (fileType == FileType.image) {
arguments.putIfAbsent('fileType', () => 'image');
} else {
arguments.putIfAbsent('fileType', () => 'video');
}
String? result;
try {
result = await _channel.invokeMethod<String>(_methodWhatsApp, arguments);
} catch (e) {
return e.toString();
}
return result;
}