MoInfiniteScrollSliver<T> constructor

const MoInfiniteScrollSliver<T>({
  1. Key? key,
  2. required PageFetcher<T> fetcher,
  3. required Widget itemBuilder(
    1. BuildContext context,
    2. T item
    ),
  4. int limit = 20,
  5. int prefetchOffset = 3,
  6. MoInfiniteScrollController<T>? controller,
  7. Widget? loadingPlaceholder,
  8. Widget? emptyPlaceholder,
  9. Widget? errorPlaceholder,
  10. Widget? loadingMoreIndicator,
  11. Widget separatorBuilder(
    1. BuildContext context,
    2. int index
    )?,
})

Implementation

const MoInfiniteScrollSliver({
  super.key,

  // ── Required ────────────────────────────────────────────────────────────
  required this.fetcher,
  required this.itemBuilder,

  // ── Pagination ──────────────────────────────────────────────────────────

  /// Number of items to request per page. Passed directly to [fetcher].
  /// Defaults to 20.
  this.limit = 20,

  /// How many items from the end should trigger a pre-fetch.
  /// Defaults to 3.
  this.prefetchOffset = 3,

  // ── External controller ─────────────────────────────────────────────────

  /// Optional external controller. Expose this to allow the parent widget
  /// (e.g. a [RefreshIndicator]) to call [MoInfiniteScrollController.refresh].
  this.controller,

  // ── Placeholders ────────────────────────────────────────────────────────

  /// Widget shown while the very first page is loading.
  /// Defaults to [DefaultLoadingPlaceholder].
  this.loadingPlaceholder,

  /// Widget shown when the list is empty after a successful fetch.
  /// Defaults to [DefaultEmptyPlaceholder].
  this.emptyPlaceholder,

  /// Widget shown when a fetch throws an error.
  /// Defaults to [DefaultErrorPlaceholder].
  this.errorPlaceholder,

  /// Widget shown at the bottom of the list while loading more pages.
  /// Defaults to a centred [CircularProgressIndicator].
  this.loadingMoreIndicator,

  /// Optional separator builder, mirroring [SliverList] usage.
  this.separatorBuilder,
});