launchWhatsappURL static method

void launchWhatsappURL(
  1. String phone,
  2. String message
)

Implementation

static void launchWhatsappURL(String phone, String message) async {
  try {
    String url = AppProperties.getWhatsappUrl().replaceAll("<phoneNumber>", phone);
    url = url.replaceAll("<message>", message);

    if (await canLaunchUrl(Uri.parse("https://$url"))) { //TODO Verify how to use constant
      await launchUrl(Uri.parse(url));
    } else {
      AppConfig.logger.i('Could not launch $url');
    }
  } catch(e) {
    AppConfig.logger.e(e.toString());
  }
}