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