getAllContacts method

Future<List<EMContact>> getAllContacts()

~english Gets all contacts from the local database.

Return The contact list.

Throws A description of the exception. See EMError. ~end

~chinese 获取本地存储的所有好友。

Return 好友列表。

Throws 如果有方法调用的异常会在这里抛出,可以看到具体错误原因。请参见 EMError。 ~end

Implementation

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