launchWhatsApp static method
dynamic
launchWhatsApp(})
Launch WhatsApp with the given telephoneNumber and message.
message is optional.
mode is optional.
url is optional, if not provided, it will use the whatsappNumber otherwise it will use the url.
Implementation
static launchWhatsApp(
String whatsAppNumber, {
String message = "Hello",
LaunchMode mode = LaunchMode.platformDefault,
String? url,
}) async {
final String whatsAppUrl =
"https://wa.me/$whatsAppNumber&text=${Uri.encodeFull(message)}";
try {
await canLaunchUrlString(url ?? whatsAppUrl)
? await launchUrlString(
url ?? whatsAppUrl,
mode: mode,
)
: showErrorNotice("Error", 'WhatsApp can\'t launch.');
} catch (e) {
logger.e(e.toString());
}
}