contacts_plugin 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new69

Flutter Contacts Plugin

pub package

A Flutter contacts plugin which provides easy access to the platform specific address book.

BranchBuild Status
developBuild Status
masterBuild Status

Features

  • Automatically check and request the necessary permissions to access the platform specific address book;
  • Read contacts from the addres book;
  • [WIP] Store new contacts in the address book;
  • [WIP] Update details of existing contacts;
  • [WIP] Delete existing contacts from the address book.

Usage

To use this plugin, add contacts_plugin as a dependency in your pubspec.yaml file. For example:

dependencies:
  contacts_plugin: '^0.0.3'

NOTE: There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. See issue Flutter#16049 for help on integration.

API

Fetch all contacts

To fetch all contacts from the address book make a call to the getContacts method:

import 'package:geolocator/contacts_plugin.dart';

List<Contact> contacts = await ContactsPlugin().getContacts();

Permissions

Android

On Android you'll need to add either the READ_CONTACTS or the WRITE_CONTACTS permissions to your Android Manifest (depending if you need read and/ or write access to the address book). Todo so open the AndroidManifest.xml file and one of the following two lines as direct children of the <manifest> tag:

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

iOS

On iOS you'll need to add the NSContactsUsageDescription to your Info.plist file in order to access the device's address book. Simply open your Info.plist file and add the following:

<key>NSContactsUsageDescription</key>
<string>This app needs access to address book.</string>

Issues

Please file any issues, bugs or feature request as an issue on our GitHub page.

Want to contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This Contacts plugin for Flutter is developed by Baseflow. You can contact us at hello@baseflow.com

0.0.3

  • Refactored the encoding and decoding of JSON messages.

0.0.2

  • Added build configuration for the build_runner

0.0.1

  • Initial release

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:contacts_plugin/contacts_plugin.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new SafeArea(
          child: ContactListWidget(),
        ),
      ),
    );
  }
}

class ContactListWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
      future: ContactsPlugin().getContacts(),
      builder: (BuildContext context, AsyncSnapshot<List<Contact>> snapshot) {
        if (!snapshot.hasData) {
          return Center(child: CircularProgressIndicator());
        }

        return ListView(
          children:
              snapshot.data.map((contact) => ContactWidget(contact)).toList(),
        );
      },
    );
  }
}

class ContactWidget extends StatelessWidget {
  final Contact _contact;

  ContactWidget(this._contact);

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: CircleAvatar(
          backgroundColor:
              Colors.primaries[Random().nextInt(Colors.primaries.length - 1)],
          child:
              Text(_contact.displayName?.substring(0, 1)?.toUpperCase() ?? "")),
      title: Text(_contact.displayName ?? "<null>"),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  contacts_plugin: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:contacts_plugin/contacts_plugin.dart';
  
Version Uploaded Documentation Archive
0.0.3 Sep 12, 2018 Go to the documentation of contacts_plugin 0.0.3 Download contacts_plugin 0.0.3 archive
0.0.2 Sep 7, 2018 Go to the documentation of contacts_plugin 0.0.2 Download contacts_plugin 0.0.2 archive
0.0.1 Sep 7, 2018 Go to the documentation of contacts_plugin 0.0.1 Download contacts_plugin 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Sep 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v0.1 release.

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
permission_handler ^2.0.0 2.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test