VOOZH about

URL: https://www.geeksforgeeks.org/flutter/making-calls-in-flutter/

⇱ Making Calls in Flutter - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Making Calls in Flutter

Last Updated : 15 Jul, 2025

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.

  • Launching the Default Phone Dialer App
  • Making Direct Phone Calls (Without Opening Dialer)


Launching the Default Phone Dialer App

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.

Steps to Implement Making Calls in Flutter application

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_name

To 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 get

Step 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.

  • The function is named here as “_makingPhoneCall” and the function is declared as “async”, so that it returns a promise.
  • The “url” variable is assigned with the required phone number, as a string. The "tel:" syntax here before the phone number, makes Flutter realize that the following number is a phone number that has to be opened in the default Phone App. It is declared as a “const”, so that the variable is not changed under any circumstance.
  • If there is a possibility to launch the URL, only then the URL is launched by calling the launch() function with the URL variable as an attribute.
  • Otherwise, it will throw/print a text with the URL value as an error message.


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:

  • This creates a raised button having the text “Call” on it.
  • For the onPressed attribute, we are calling "_makingPhoneCall" so that when the button is pressed, the default Phone app is opened and the phone number in the URL variable is dialed automatically, making it easier for the user.

Complete Source Code

main.dart

Output:



Making Direct Phone Calls (Without Opening Dialer)

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.

Steps to Implement Making Calls in Flutter application

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_name

To 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 get

Step 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


Complete Source code

main.dart:


Output:


Comment
Article Tags:

Explore