flutter_contacts 0.0.1 copy "flutter_contacts: ^0.0.1" to clipboard
flutter_contacts: ^0.0.1 copied to clipboard

outdated

Full-fledged flutter plugin to read, write and observe native contacts.

flutter_contacts #

Fluter plugin to read, create, update, delete and observe native contacts.

For a minimalistic example, take a look at example/. You can write a full-fledged contacts app with it – see example_full/ to see how.

Features #

  • List all contacts
  • Create new contact
  • Update existing contact
  • Delete contacts
  • Observe contact database changes
  • Fetch all details for a given contact, including:
    • Photo (low / high resolution)
    • Phones
    • Emails
    • Company / job title
    • Postal addresses
    • Websites
    • Birthday / events
    • Instant messaging / social profiles
    • Notes
    • Labels (such as "main" or "work" for phones)

Screenshots #

screenshot1 screenshot2 screenshot3 screenshot4 screenshot5

Usage #

import 'package:flutter_contacts/flutter_contacts.dart';

/// Get all contacts (IDs and names only)
List<Contact> contacts = await FlutterContacts.getContacts();

/// Get all fields (phones, emails, photo, job, etc) for a given contact
Contact contact = await FlutterContacts.getContact(contacts.first.id);

/// Create contact
Contact newContact = Contact.create()
    ..name = Name(first: 'John', last: 'Doe')
    ..phones = [Phone('555-123-4567', label: PhoneLabel.mobile)];
await FlutterContacts.newContact(newContact);

/// Update contact
contact.emails.add(Email('john.doe@example.com'));
await FlutterContacts.updateContact(contact);

/// Delete contact
await FlutterContacts.deleteContact(contact.id);

/// Listen to contacts database changes
FlutterContacts.onChange(() => print('Contact DB changed'));

Installation #

  1. Add json_serializable: ^3.5.0 (or higher) to the dev_dependencies in pubspec.yaml.
  2. Add permission_handler: ^5.0.0+hotfix.3 (or higher) to the dependencies in pubspec.yaml: this is the package that allows you to request for contact permissions.
  3. Add the following <uses-permissions> tags to AndroidManifest.xml (for Android):
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ...>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <application ...>
    ...

Development notes #

Run build_runner to generate g.dart files #

flutter pub run build_runner build

Format files #

./scripts/format.sh
328
likes
0
pub points
99%
popularity

Publisher

verified publisherquis.co

Full-fledged flutter plugin to read, write and observe native contacts.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

diacritic, flutter, json_annotation

More

Packages that depend on flutter_contacts