パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.9.1+8

flutter_contact

Android および iOS デバイス上で連絡先と関連イベントを取得、作成、保存するための Flutter プラグインです。

AndroidiOS
30日間ダウンロード
75
いいね数
60
Pub ポイント
120

パッケージをインストール

flutter pub add flutter_contact

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

flutter_contact は、Android および iOS デバイス上で連絡先や関連イベントにアクセス、作成、管理できるようにする Flutter プラグインです。ネイティブの連絡先システムとやり取りするための一元的なインターフェースを提供し、ユーザーが連絡先の詳細情報を取得したり、新しい連絡先を追加したり、連絡先の変更を処理できるようにします。このプラグインは、連絡先リストの読み取り、連絡先情報の追加または更新、連絡先の写真の管理などの基本操作をサポートしています。最小限の構成で、プラットフォーム間でシームレスに動作するように設計されています。

用途

  • デバイスの連絡先リストにアクセスする
  • プログラムで新しい連絡先を作成する
  • 既存の連絡先情報を更新する
  • 連絡先写真の管理
  • アプリデータとの連絡先の同期
  • 連絡先ピッカー機能の統合

主な機能

  • クロスプラットフォーム対応(Android および iOS)
  • 連絡先情報を取得および管理する
  • 連絡先の追加、更新、削除
  • 連絡先の写真のサポート
  • イベント駆動型の連絡先変更検出
  • 一般的な連絡先操作向けのシンプルな API

適している対象

  • 連絡先管理アプリ
  • CRM アプリケーション
  • ユーザープロファイルの同期
  • 連絡先統合付きの通信アプリ
  • 連絡先のインポート/エクスポートを必要とするアプリ

注意事項

  • 両プラットフォームで適切な権限が必要です
  • 基本的な連絡先操作に限定
  • 複雑な連絡先フィールドには追加の処理が必要になる場合があります
  • プラットフォーム固有の振る舞いの違い
  • 連絡先アクセスに関連するプライバシー上の懸念
  • 権限の拒否に対する適切なエラーハンドリングが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_contact

pub package Coverage Status

A Flutter plugin to access and manage the device's native contacts.

Usage

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

dependencies:  
    flutter_contact: ^0.6.1

Permissions

Android

Add the following permissions to your AndroidManifest.xml:

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

Set the NSContactsUsageDescription in your Info.plist file

<key>NSContactsUsageDescription</key>  
<string>Your description of why you are requesting permissions.</string>  

Note
flutter_contact does not handle the process of asking and checking for permissions. To check and request user permission to access contacts, try using the following plugins: flutter_simple_permissions or permission_handler.

If you do not request user permission or have it granted, the application will fail. For testing purposes, you can manually set the permissions for your test app in Settings for your app on the device that you are using. For Android, go to "Settings" - "Apps" - select your test app - "Permissions" - then turn "on" the slider for contacts.

Unified vs Single contacts

There are two main entry points into the application: SingleContacts and UnifiedContacts. These share the same API and most of the underlying code, however:

  • SingleContacts will interact with the unlinked raw contacts on each platform
  • UnifiedContacts will interact with linked/aggregated contacts on each platform.

Memory Efficiency

This plugin tries to be memory and cpu friendly. It avoid loading your entire address book into memory, but rather provides some ways to iterate over contacts in a more memory friendly way:

Stream
import 'package:flutter_contact/contact.dart';  

// By default, this will loop through all contacts using a page size of 20.
await Contacts.streamContacts().forEach((contact) {
    print("${contact.displayName}");
});

// You can manually adjust the buffer size
Stream<Contact> contacts = await Contacts.streamContacts(bufferSize: 50);
Paging List

The second option is a paging list, which also uses an underlying page buffer, but doesn't have any subscriptions to manage, and has some other nice features, like a total count

import 'package:flutter_contact/contact.dart';

final contacts = Contacts.listContacts();
final total = await contacts.length;

// This will fetch the page this contact belongs to, and return the contact
final contact = await contacts.get(total - 1);

while(await contacts.moveNext()) {
    final contact = await contacts.current;
}

Example

// Import package  
import 'package:flutter_contact/contact.dart';  
  
// Get all contacts on device as a stream
Stream<Contact> contacts = await Contacts.streamContacts();  

// Get all contacts without thumbnail(faster)
Iterable<Contact> contacts = await Contacts.streamContacts(withThumbnails: false);
  
// Get contacts matching a string
Stream<Contact> johns = await Contacts.streamContacts(query : "john");

// Add a contact  
// The contact must have a firstName / lastName to be successfully added  
await Contacts.addContact(newContact);  
  
// Delete a contact
// The contact must have a valid identifier
await Contacts.deleteContact(contact);  

// Update a contact
// The contact must have a valid identifier
await Contacts.updateContact(contact);

/// Lazily fetch avatar data without caching it in the contact instance.
final contact = Contacts.getContact(contactId);
final Uint8List avatarData = await contact.getOrFetchAvatar();

Credits

This plugin was originally a fork of the https://pub.dev/packages/flutter_contact plugin, but has effectively been mostly rewritten (in part because it was ported to kotlin)

カテゴリー

依存関係

依存関係一覧 9 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。