fcontacts

pub package

A Flutter plugin for accessing to all available data from your phone contacts. Supports iOS and Android.

Getting Started

In Android, you need to add the READ_CONTACTS permission in your AndroidManifest.xml.

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

In iOS, you need to add the key NSContactsUsageDescription in your Info.plist file.

<key>NSContactsUsageDescription</key>
<string>We need access to your contacts for this demo</string>

Usage

Import package

To use this plugin you must add fcontacts as a dependency in your pubspec.yaml file.

dependencies:
    fcontacts: ^0.0.3

Example

import 'package:fcontacts/fcontacts.dart';

Listing all the contacts in your device:

List<FContact> allContacts = await FContacts.all();

Listing contacts filtered by a query string:

List<FContact> filteredContacts = await FContacts.list( query: "abc" );
// The fields used to filter are:
//  - identifier
//  - displayName
//  - nickname
//  - jobTitle
//  - departmentName
//  - organizationName
//  - note
//  - postalAddresses (street, city, subLocality, subAdministrativeArea, postalCode, state, country)
//  - emails
//  - urls
//  - phoneNumbers
//  - socialProfiles (service, userIdentifier, username, url)
//  - contactRelations
//  - instantMessageAddresses (service, username)

Models

FContact

class FContact {
    String identifier;
    String displayName;
    String contactType;
    String namePrefix;
    String givenName;
    String middleName;
    String familyName;
    String previousFamilyName;              // Only in iOS
    String nameSuffix;
    String nickname;
    String phoneticGivenName;               // Only in iOS
    String phoneticMiddleName;              // Only in iOS
    String phoneticFamilyName;              // Only in iOS
    String jobTitle;
    String departmentName;                  // Only in iOS
    String organizationName;
    String phoneticOrganizationName;        // Only in iOS
    int birthdayDay;
    int birthdayMonth;
    int birthdayYear;
    String note;                            // Only in Android
    Uint8List image;
    Uint8List thumbnail;

    List<FContactDateLabeled> dates;
    List<FContactPostalAddressLabeled> postalAddresses;
    List<FContactValueLabeled> emails;
    List<FContactValueLabeled> urls;
    List<FContactValueLabeled> phoneNumbers;
    List<FContactSocialProfileLabeled> socialProfiles;                      // Only in iOS
    List<FContactValueLabeled> contactRelations;
    List<FContactInstantMessageAddressLabeled> instantMessageAddresses;

}

FContactValueLabeled

class FContactValueLabeled {
    String label;
    String value;
}

FContactDateLabeled

class FContactDateLabeled {
    String label;
    int day;
    int month;
    int year;
}

FContactPostalAddressLabeled

class FContactPostalAddressLabeled {
    String label;
    String street;
    String city;
    String subLocality;
    String subAdministrativeArea;
    String postalCode;
    String state;
    String country;
    String isoCountryCode;
    String formatted;
}

FContactSocialProfileLabeled

class FContactSocialProfileLabeled {
    String label;
    String service;
    String userIdentifier;
    String username;
    String url;
}

FContactInstantMessageAddressLabeled

class FContactInstantMessageAddressLabeled {
    String label;
    String service;
    String username;
}

Limitations

  • The Notes field in iOS is not available for now.

Credits

This plugin has been created and developed by Daniel Martínez.

Any suggestions and contributions are welcomed. Thanks for using this plugin!

Libraries

fcontacts

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]