doInitialLoad method

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

Load initial data from the server.

Implementation

@override
Future<void> doInitialLoad() async {
  try {
    final assets = await _getRecentAssetPathList();

    if (assets == null) {
      value = const PagedValue(items: []);
      return;
    }

    final mediaList = await assets.getAssetListPaged(
      page: 0,
      size: limit,
    );

    final nextKey = mediaList.length < limit ? null : 1;
    value = PagedValue(
      items: mediaList,
      nextPageKey: nextKey,
    );
  } on StreamChatError catch (error) {
    value = PagedValue.error(error);
  } catch (error) {
    final chatError = StreamChatError(error.toString());
    value = PagedValue.error(chatError);
  }
}