Example of Dial Phone Number From Flutter App | Make a Call

Hello friends, In today’s tutorial we would learn about making a call directly from flutter application. Now how this works is? We have a TextField widget and a button in our UI. Now we have to type number in our flutter app and when we click on the button then it will automatically redirect us to the Phone Dial screen with our number typed also. We are using flutter’s url_launcher pub package in our project to implement this functionality. So in this tutorial we would learn about Example of Dial Phone Number From Flutter App.

Contents in this project Example of Dial Phone Number From Flutter App :-

1. First of all we have to install the url_launcher pub package in our flutter project. So open your flutter project Root directory in Command Prompt or Terminal and execute below command.

Screenshot after done installation :-

2. Now we have to manually add Android Dial Intent in our AndroidManifest.xml file. So open Your_Flutter_Project -> android -> app -> src -> main -> AndroidManifest.xml file. and put below Intent code inside it.

Source Code of my AndroidManifest.xml file after adding above code :-

3. Now open your project’s main.dart file and import material.dart and url_launcher.dart package.

4. Creating our void main runApp() method and here we would call our main MyApp class.

5. Creating our main MyApp extends StatelessWidget class. In this class we would call our Dial() class.

6. Creating Dial extends StatefulWidget class. In this class we would make DialScreen with createState() method to enable mutable state management.

7. Creating our main DialScreen extends State<Dial> class.

8. Creating a TextEditingController named as number. It is used to extract typed data from TextField widget.

9. Creating a Future type _dialCall() ASYNC function. In this function we would simply get the number from TextField widget and open the Dial screen.

10. Creating Widget Build area -> Here we would make 1 TextField widget and 1 Button widget.

11. Complete source code for main.dart file :-

Screenshots :-

Example of Dial Phone Number From Flutter App | Make a Call

Leave a Reply

Your email address will not be published. Required fields are marked *