makePhoneCall static method

Future<void> makePhoneCall(
  1. String phoneNumber
)

A function to make a phone call.

It takes a String which is the phone number to be called.

It will try to launch the phone call with LaunchMode.externalApplication.

If the launch fails, it will throw an Exception.

Implementation

static Future<void> makePhoneCall(String phoneNumber) async {
  final phoneUri = Uri(scheme: 'tel', path: phoneNumber);
  if (await canLaunchUrl(phoneUri)) {
    await launchUrl(phoneUri); // Launch the phone call
  } else {
    throw 'Could not launch phone call';
  }
}