fetchPublicGroupsFromServer method Null safety

Future<EMCursorResult<EMGroup>> fetchPublicGroupsFromServer(
  1. {int pageSize = 200,
  2. String? cursor}
)

Gets public groups from the server with pagination.

Param pageSize The number of public groups per page.

Param cursor The cursor position from which to start to get data next time. Sets the parameter as null for the first time.

Return The result of {@link EMCursorResult}, including the cursor for getting data next time and the group list. If EMCursorResult.cursor is an empty string (""), all data is fetched.

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

Implementation

Future<EMCursorResult<EMGroup>> fetchPublicGroupsFromServer({
  int pageSize = 200,
  String? cursor,
}) async {
  Map req = {'pageSize': pageSize};
  req.setValueWithOutNull("cursor", cursor);
  Map result = await _channel.invokeMethod(
      ChatMethodKeys.getPublicGroupsFromServer, req);
  try {
    EMError.hasErrorFromResult(result);
    return EMCursorResult<EMGroup>.fromJson(
        result[ChatMethodKeys.getPublicGroupsFromServer],
        dataItemCallback: (value) {
      return EMGroup.fromJson(value);
    });
  } on EMError catch (e) {
    throw e;
  }
}