getAllContactsFromDB method Null safety

Future<List<String>> getAllContactsFromDB()

Gets the contact list from the local database.

Return The contact list.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<List<String>> getAllContactsFromDB() async {
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getAllContactsFromDB);
  try {
    EMError.hasErrorFromResult(result);
    List<String> contacts = [];
    result[ChatMethodKeys.getAllContactsFromDB]?.forEach((element) {
      contacts.add(element);
    });

    return contacts;
  } on EMError catch (e) {
    throw e;
  }
}