fetchAllContacts method

Future<List<ChatContact>> fetchAllContacts()

Gets all contacts from the server.

Return The contact list.

Throws A description of the exception. See ChatError.

Implementation

Future<List<ChatContact>> fetchAllContacts() async {
  try {
    Map result = await platform_interface.Client.instance.contactManager
        .callNativeMethod(ChatMethodKeys.fetchAllContacts);
    ChatError.hasErrorFromResult(result);
    List<ChatContact> list = [];
    result[ChatMethodKeys.fetchAllContacts]?.forEach((element) {
      list.add(ChatContact.fromJson(element));
    });
    return list;
  } catch (e) {
    rethrow;
  }
}