# ContactsPlugin **Repository Path**: coolxinxins/ContactsPlugin ## Basic Information - **Project Name**: ContactsPlugin - **Description**: Contacts Flutter project(联系人选择器,获取联系人列表) - **Primary Language**: Dart - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2023-04-10 - **Last Updated**: 2023-04-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # contacts_plugin ## 支持Android和iOS端 [获取联系人和选择联系人使用示例](https://github.com/coolxinxin/ContactsPlugin/blob/main/example/lib/main.dart) ### 使用 ``` flutter pub add contacts_plugin_plus //终端运行此命令 ``` ``` dependencies: contacts_plugin_plus: any ``` #### 选择联系人 ``` ContactsPlugin.selectContact().then((value) { // if (value != null) { // var name = value["name"] ?? ""; // var number = value["number"] ?? ""; var name = value.name ?? ""; var number = value.number ?? ""; setState(() { selectText = name + "/" + number; }); // } }); ``` #### 获取全部联系人 ``` ContactsPlugin.getAllContacts().then((value) { for (var contact in value) { var number = ""; if (contact.phones != null && contact.phones!.isNotEmpty) { number = contact.phones?.first.value ?? ""; } var name = contact.otherName ?? ""; debugPrint("phone:" + number); debugPrint("name:" + name); } setState(() { allContacts = "The number of all contacts is:" + value.length.toString(); }); }); ```