launchMessage static method

dynamic launchMessage(
  1. String telephoneNumber, {
  2. String? message,
  3. LaunchMode mode = LaunchMode.platformDefault,
})

Launch Message app with the given message.

Implementation

static launchMessage(String telephoneNumber,
    {String? message, LaunchMode mode = LaunchMode.platformDefault}) async {
  String telephoneUrl = "sms:$telephoneNumber?body=$message";
  if (await canLaunchUrlString(telephoneUrl)) {
    await launchUrlString(
      telephoneUrl,
      mode: mode,
    );
  } else {
    showErrorNotice("Error", "Could not launch the $telephoneNumber number");
    throw "Can't message that number.";
  }
}