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

パッケージ詳細v0.0.13

flutter_native_contact_picker

アドレス帳から連絡先を選択するためのFlutterプラグインです。

AndroidiOS
30日間ダウンロード
5.8万
いいね数
82
Pub ポイント
160

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

flutter pub add flutter_native_contact_picker

パッケージ概要

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

AndroidおよびiOSデバイスのネイティブアドレス帳から連絡先を直接選択できるFlutterプラグインです。プラットフォームに合わせた自然なインターフェースを提供し、複数のプラットフォーム間で一貫したユーザー体験を実現します。デバイスの内蔵連絡先システムと統合されており、名前、電話番号、メールアドレスなどの連絡先情報を取得できます。シンプルかつ信頼性が高く、カスタム連絡先ピッカーを構築せずに連絡先の統合が必要なアプリに最適です。

用途

  • メッセージアプリでの連絡先選択の統合
  • 連絡先のインポートによるユーザープロファイル作成の有効化
  • 迅速な連絡先共有の促進
  • 連絡先検索による予約スケジューリングのサポート
  • 連絡先の取得を使ってCRMツールを構築する

主な機能

  • Android および iOS のネイティブ連絡先ピッカー UI
  • 名前や電話番号などの連絡先情報へのアクセス
  • 連絡先選択のためのシンプルな API
  • クロスプラットフォーム互換性
  • プラットフォームの権限を使用した安全なデータ処理

適している対象

  • 通信アプリを開発する開発者
  • 連絡先のインポート機能を必要とするアプリ
  • リードジェネレーションまたはネットワーキング向けツール
  • 連絡先入力が必要なモバイルフォーム
  • ユーザーのオンボーディングフローを備えたアプリケーション

注意事項

  • Android および iOS で実行時権限が必要です
  • すべての連絡先フィールド(例:写真)をサポートしない可能性があります
  • デバイスのネイティブ連絡先データベースに依存します
  • ピッカーUIのカスタマイズが限定的
  • 権限の拒否に対する適切なエラーハンドリングが必要です

元の README

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

flutter_native_contact_picker

With this plugin a Flutter app can ask its user to select a contact or contacts from their address book, with the option to select specific phone numbers. The information associated with the contacts is returned to the app.

This plugin uses the operating system's native UI for selecting contacts and does not require any special permissions from the user, even on Android.

Features

  • [x] iOS Support

    • Select single contact
    • Select multiple contacts
    • Select specific phone number from a contact
    • Returns all phone numbers for selected contacts
  • [x] Android Support

    • Select single contact
    • Select specific phone number from a contact
    • No READ_CONTACTS permission required

Usage

Basic Contact Selection
// Create an instance of the picker
final FlutterNativeContactPicker _contactPicker = FlutterNativeContactPicker();

// Select a single contact
Contact? contact = await _contactPicker.selectContact();
print(contact?.fullName);
print(contact?.phoneNumbers);

// Select multiple contacts (iOS only)
List<Contact>? contacts = await _contactPicker.selectContacts();
for (var contact in contacts ?? []) {
  print(contact.fullName);
  print(contact.phoneNumbers);
}
Phone Number Selection
// Select a specific phone number from a contact
Contact? contact = await _contactPicker.selectPhoneNumber();
print(contact?.fullName);
print(contact?.selectedPhoneNumber); // The specifically selected number
print(contact?.phoneNumbers); // All available numbers (iOS only)

Contact Model

The Contact class provides the following properties:

class Contact {
  final String? fullName;           // Contact's full name
  final List<String>? phoneNumbers; // All phone numbers (iOS: all numbers, Android: selected number only)
  final String? selectedPhoneNumber; // The specifically selected phone number when using selectPhoneNumber()
}

Platform Differences

iOS
  • Minimum iOS 13.0 (Swift Package Manager integration and Flutter FlutterFramework requirement)
  • Supports selecting multiple contacts
  • Returns all phone numbers associated with a contact
  • When using selectPhoneNumber(), returns both the selected number and all available numbers
  • Uses native CNContactPickerViewController
Android
  • Single contact selection only
  • When using selectPhoneNumber(), returns only the selected phone number
  • No READ_CONTACTS permission required
  • Uses native contact picker intent

Example

See the example directory for a complete sample app demonstrating all features.

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final FlutterNativeContactPicker _contactPicker = FlutterNativeContactPicker();
  List<Contact>? _contacts;
  String? _selectedPhoneNumber;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Contact Picker Example App'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              MaterialButton(
                color: Colors.blue,
                textColor: Colors.white,
                child: const Text("Select Contact"),
                onPressed: () async {
                  Contact? contact = await _contactPicker.selectContact();
                  setState(() {
                    _contacts = contact == null ? null : [contact];
                    _selectedPhoneNumber = null;
                  });
                },
              ),
              MaterialButton(
                color: Colors.green,
                textColor: Colors.white,
                child: const Text("Select Phone Number"),
                onPressed: () async {
                  Contact? contact = await _contactPicker.selectPhoneNumber();
                  setState(() {
                    _contacts = contact == null ? null : [contact];
                    _selectedPhoneNumber = contact?.selectedPhoneNumber;
                  });
                },
              ),
              if (_contacts != null) ...[
                ..._contacts!.map(
                  (contact) => Column(
                    children: [
                      Text(contact.fullName ?? 'No name'),
                      if (_selectedPhoneNumber != null)
                        Text('Selected: $_selectedPhoneNumber'),
                      ...?contact.phoneNumbers?.map((number) => Text(number)),
                    ],
                  ),
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.0.2

ソースリポジトリ

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