How to Access Contacts in Flutter Application (Read and Make Phone calls)

Written by mouli150388 on Feb 27th, 2022 Views Report Post

How to get Phone call list and display on Listview in Flutter application.

This post will show how to read phone contacts and make phone calls from flutter application.

Read Contacts from device

For this example we are going to use flutter_contact plugin to fetch the contacts from Phone contacts

Dependencies

Add required dependenices in pubspec.yaml file

flutter_contact : Read Contacts from Phone

permission_handler : Handle Permissionrequest for Android Marshmallow and above versions

url_launcher : Make phone call from application

flutter_contact: ^0.6.4
permission_handler: ^5.0.1+1
url_launcher: ^5.7.2

Add required Permissions

Update manifest file with adding below permisions

<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>

iOS Set Up

Add permissions for iOS into the info.plist file

<key>NSAppleMusicUsageDescription</key>
<string>Music!</string>
<key>kTCCServiceMediaLibrary</key>
<string>media</string>
<key>NSCalendarsUsageDescription</key>
<string>Calendars</string>
<key>NSCameraUsageDescription</key>
<string>camera</string>
<key>NSContactsUsageDescription</key>
<string>contacts</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphone</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>speech</string>
<key>NSMotionUsageDescription</key>
<string>motion</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photos</string>
<key>NSRemindersUsageDescription</key>
<string>reminders</string>

Read Contacts

We need to write below lines of code to fetch the contacts from Phone contacts

Contacts.streamContacts().forEach((contact) {
  print("${contact.displayName}");

    });

Download complete code for Fetch contacts from Phone and make a phone call in fllutter

Comments (0)