getContact method

  1. @override
Future<Contact?> getContact(
  1. String id, {
  2. bool withProperties = true,
  3. bool withThumbnail = false,
  4. bool withPhoto = false,
})
override

Gets a specific contact by ID.

id - The contact ID to retrieve. withProperties - Include phone numbers, emails, etc. withThumbnail - Include thumbnail image. withPhoto - Include full-size photo.

Implementation

@override
Future<Contact?> getContact(
  String id, {
  bool withProperties = true,
  bool withThumbnail = false,
  bool withPhoto = false,
}) async {
  try {
    final result = await methodChannel.invokeMethod<dynamic>(
      'getContact',
      {
        'id': id,
        'withProperties': withProperties,
        'withThumbnail': withThumbnail,
        'withPhoto': withPhoto,
      },
    );

    return result != null ? Contact.fromJson(_safeMapCast(result)) : null;
  } on PlatformException catch (e) {
    throw Exception('Failed to get contact: ${e.message}');
  }
}