flutter_contact는 Android 및 iOS 기기에서 연락처와 관련 이벤트에 액세스하고 생성하며 관리할 수 있도록 해주는 플러터 플러그인입니다. 원격 연락처 시스템과 상호작용하기 위한 통합 인터페이스를 제공하여 사용자가 연락처 세부 정보를 가져오거나 새 연락처를 추가하거나 연락처 변경 사항을 처리할 수 있게 합니다. 이 플러그인은 연락처 목록 읽기, 연락처 정보 추가 또는 업데이트, 연락처 사진 관리 등의 기본 작업을 지원합니다. 최소한의 구성으로 플랫폼 간에 원활하게 작동하도록 설계되었습니다.
사용 사례
장치 연락처 목록에 액세스
프로그래밍적으로 새 연락처 만들기
기존 연락처 세부 정보 업데이트
연락처 사진 관리
앱 데이터와 연락처 동기화
연락처 선택기 기능 통합
주요 기능
크로스 플랫폼 지원 (Android 및 iOS)
연락처 세부 정보 검색 및 관리
연락처 추가, 업데이트 및 삭제
연락처 사진 지원
이벤트 기반의 연락처 변경 감지
일반적인 연락처 작업을 위한 간단한 API
적합한 대상
연락처 관리 앱
CRM 애플리케이션
사용자 프로필 동기화
연락처 통합이 가능한 통신 앱
연락처 가져오기/내보내기 필요 앱
고려 사항
두 플랫폼 모두 적절한 권한이 필요합니다
기본 연락처 작업에 한정
복잡한 연락처 필드 처리를 위해 추가 조치가 필요할 수 있습니다
플랫폼별 동작 차이
연락처 접근과 관련된 개인정보 보호 우려
권한 거부에 대한 적절한 오류 처리가 필요합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
flutter_contact
A Flutter plugin to access and manage the device's native contacts.
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.awaitContacts.streamContacts().forEach((contact) {
print("${contact.displayName}");
});
// You can manually adjust the buffer sizeStream<Contact> contacts = awaitContacts.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 contactfinal 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 streamStream<Contact> contacts = awaitContacts.streamContacts();
// Get all contacts without thumbnail(faster)Iterable<Contact> contacts = awaitContacts.streamContacts(withThumbnails: false);
// Get contacts matching a stringStream<Contact> johns = awaitContacts.streamContacts(query : "john");
// Add a contact // The contact must have a firstName / lastName to be successfully added awaitContacts.addContact(newContact);
// Delete a contact// The contact must have a valid identifierawaitContacts.deleteContact(contact);
// Update a contact// The contact must have a valid identifierawaitContacts.updateContact(contact);
/// Lazily fetch avatar data without caching it in the contact instance.final contact = Contacts.getContact(contactId);
finalUint8List 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)