queryContact method
Implementation
Future<Contact?> queryContact(String? address) async {
if (address == null) {
throw ("address is null");
}
if (queried.containsKey(address) && queried[address] != null) {
return queried[address];
}
if (inProgress.containsKey(address) && inProgress[address] == true) {
throw ("already requested");
}
inProgress[address] = true;
return await _channel.invokeMethod("getContact", {"address": address}).then(
(dynamic val) async {
Contact contact = Contact.fromJson(address, val);
if (contact.thumbnail != null) {
await contact.thumbnail!._readBytes();
}
if (contact.photo != null) {
await contact.photo!._readBytes();
}
queried[address] = contact;
inProgress[address] = false;
return contact;
});
}