getAllContacts method
Future<List<Contact> >
getAllContacts({
- bool withProperties = false,
- bool withThumbnail = false,
- bool withPhoto = false,
- bool sorted = true,
override
Gets all contacts from the device.
withProperties
- Include phone numbers, emails, etc.
withThumbnail
- Include thumbnail images.
withPhoto
- Include full-size photos.
sorted
- Sort contacts alphabetically.
Implementation
@override
Future<List<Contact>> getAllContacts({
bool withProperties = false,
bool withThumbnail = false,
bool withPhoto = false,
bool sorted = true,
}) async {
try {
final result = await methodChannel.invokeMethod<List<dynamic>>(
'getAllContacts',
{
'withProperties': withProperties,
'withThumbnail': withThumbnail,
'withPhoto': withPhoto,
'sorted': sorted,
},
);
return result
?.map<Contact>(
(dynamic item) => Contact.fromJson(_safeMapCast(item)),
)
.toList() ??
<Contact>[];
} on PlatformException catch (e) {
throw Exception('Failed to get contacts: ${e.message}');
}
}