fetchNext method

Future<List<GroupMember>> fetchNext({
  1. required dynamic onSuccess(
    1. List<GroupMember> groupList
    )?,
  2. required dynamic onError(
    1. CometChatException excep
    )?,
})

fetch the list of Users that logged-in user have blocked.

Implementation

Future<List<GroupMember>> fetchNext(
    {required Function(List<GroupMember> groupList)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final result = await channel.invokeMethod('fetchBlockedGroupMembers', {
      'limit': this.limit,
      'searchKeyword': this.searchKeyword,
      'guid': this.guid,
      'scopes': this.scopes,
      'key': this.key
    });
    final List<GroupMember> res = [];
    if (result != null) {
      key = result["key"];
      if (result["list"] != null) {
        for (var _obj in result["list"]) {
          try {
            res.add(GroupMember.fromMap(_obj));
          } catch (e) {
            if (onError != null) {
              onError(CometChatException(ErrorCode.errorUnhandledException,
                  e.toString(), e.toString()));
            }
            return [];
          }
        }
      }
    }
    if (onSuccess != null) {
      onSuccess(res);
    }
    return res;
  } on PlatformException catch (platformException) {
    if (onError != null) {
      onError(CometChatException(platformException.code,
          platformException.details, platformException.message));
    }
  } catch (e) {
    if (onError != null) {
      onError(CometChatException(
          ErrorCode.errorUnhandledException, e.toString(), e.toString()));
    }
  }
  return [];
}