paginatedItemBuilderWithEndLoader method

Widget paginatedItemBuilderWithEndLoader(
  1. BuildContext context,
  2. int index, [
  3. Animation<double>? animation
])

Implementation

Widget paginatedItemBuilderWithEndLoader(
  BuildContext context,
  int index, [
  Animation<double>? animation,
]) {
  final itemLocation = index + 1;
  final isAtEnd = itemLocation == _cachedItems.length;
  final nextChunkIsLoading = nextAvailableChunk.status != ChunkStatus.last;

  /// Builds the item from user code or shows an error widget
  Widget buildGuardedItem() {
    try {
      return paginatedItemBuilder(
        context,
        index,
        animation,
      );
    } catch (e) {
      return widget.itemErrorWidgetBuilder?.call(e) ?? DefaultErrorCard(e);
    }
  }

  return isAtEnd && nextChunkIsLoading && widget.shouldShowItemLoader
      ? widget.itemLoadingWidget!
      : buildGuardedItem();
}