搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫jayeshpansheriya/flutter_native_contact_picker

flutter_native_contact_picker

使用此外掛,Flutter 應用程式可以要求使用者從其通訊錄中選擇聯絡人。與聯絡人相關的資訊將回傳給應用程式。

flutter_native_contact_picker 專案封面
星標
61
分支
35
最近推送(UTC)
2026年4月27日
專案狀態
未封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

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)),
                    ],
                  ),
                ),
              ],
            ],
          ),
        ),
      ),
    );
  }
}
Jayesh Pansheriya  GitHub avatar
GitHub 作者

Jayesh Pansheriya ↗

Mobile App Developer

Ahmedabad, India
語言DartKotlinSwiftRubyObjective-C

分類

此儲存庫發佈的套件

使用的依賴

依賴清單 4 項

  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴^6.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗