doInitialLoad method

  1. @override
Future<void> doInitialLoad()
override

Load initial data from the server.

Implementation

@override
Future<void> doInitialLoad() async {
  final limit = min(
    this.limit * defaultInitialPagedLimitMultiplier,
    _kDefaultBackendPaginationLimit,
  );
  try {
    final response = await channel.queryPollVotes(
      pollId,
      sort: _activeSort,
      filter: _activeFilter,
      pagination: PaginationParams(limit: limit),
    );

    final results = response.votes;
    final nextKey = response.next;
    value = PagedValue(
      items: results,
      nextPageKey: nextKey,
    );

    // start listening to events
    _subscribeToPollVoteEvents();
  } on StreamChatError catch (error) {
    value = PagedValue.error(error);
  } catch (error) {
    final chatError = StreamChatError(error.toString());
    value = PagedValue.error(chatError);
  }
}