![]() |
VOOZH | about |
In this online world, customer care plays a major role in the success of a company. Users are quite satisfied when they converse with the executives through calls. This has forced companies to add phone numbers to their apps for their customers to contact them easily. But dialing those numbers from the app into the default phone app makes it quite cumbersome. So, to improve the user experience, Flutter has come up with a feature where the user can call the other, just with a click.
In Flutter, there are two ways to make a phone call.
In this process, the default phone app will be used to make a call; it will open the app directly, and the number will be automatically filled in the text field.
Step 1: Create a New Flutter Application
Create a new Flutter application using the command Prompt. To create a new app, write the below command and run it.
flutter create app_nameTo know more about it refer this article: Creating a Simple Application in Flutter
Step 2: Adding the Dependency
To add the dependency to the pubspec.yaml file, add url_launcher as a dependency in the dependencies part of the pubspec.yaml file, as shown below:
Now run the below command in the terminal.
flutter pub getStep 3: Importing the Dependency
Use the below line of code in the main.dart file, to import the url_launcher dependency :
import 'package:url_launcher/url_launcher.dart';Step 4: Follow the Below Steps
1. _m
Now, let’s create a function that can be called whenever the user clicks a button,that’s linked to a phone number, o make a call.
2.
The above function can be called when needed inside the program by calling the name of the functions as it is. The example is as follows:
main.dart
In this process, the specific number will be called directly from our Flutter app, unlike the previous method, which opens the default phone app on your mobile device.
Step 1: Create a New Flutter Application
Create a new Flutter application using the command Prompt. To create a new app, write the below command and run it.
flutter create app_nameTo know more about it refer this article: Creating a Simple Application in Flutter
Step 2: Adding the Dependency
To add the dependency to the pubspec.yaml file, add direct_phone_call as a dependency in the dependencies part of the pubspec.yaml file, as shown below:
Now run the below command in the terminal.
flutter pub getStep 3: Importing the Dependency
Use the below line of code in the main.dart file, to import the direct_phone_call dependency :
import 'package:direct_phone_call/direct_phone_call.dart'; Step 4: Method to make a phone call
main.dart:
Output: