SmartPagination<T>.listViewWithCubit constructor

SmartPagination<T>.listViewWithCubit({
  1. Key? key,
  2. required SmartPaginationCubit<T> cubit,
  3. required Widget itemBuilder(
    1. BuildContext context,
    2. List<T> documents,
    3. int index
    ),
  4. double? heightOfInitialLoadingAndEmptyWidget,
  5. Widget onError(
    1. Exception exception
    )?,
  6. void onReachedEnd(
    1. SmartPaginationLoaded<T> loader
    )?,
  7. void onLoaded(
    1. SmartPaginationLoaded<T> loader
    )?,
  8. Widget emptyWidget = const EmptyDisplay(),
  9. Widget loadingWidget = const InitialLoader(),
  10. Widget bottomLoader = const BottomLoader(),
  11. bool shrinkWrap = false,
  12. bool reverse = false,
  13. Axis scrollDirection = Axis.vertical,
  14. EdgeInsetsGeometry padding = const EdgeInsetsGeometry.all(0),
  15. ScrollPhysics? physics,
  16. ScrollController? scrollController,
  17. bool allowImplicitScrolling = false,
  18. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  19. Widget? header,
  20. Widget? footer,
  21. SmartPaginationLoaded<T> beforeBuild(
    1. SmartPaginationLoaded<T> state
    )?,
  22. ListBuilder<T>? listBuilder,
  23. double? cacheExtent,
  24. Widget? separator,
  25. double spacing = 4,
  26. Widget firstPageLoadingBuilder(
    1. BuildContext context
    )?,
  27. Widget firstPageErrorBuilder(
    1. BuildContext context,
    2. Exception error,
    3. VoidCallback retry
    )?,
  28. Widget firstPageEmptyBuilder(
    1. BuildContext context
    )?,
  29. Widget loadMoreLoadingBuilder(
    1. BuildContext context
    )?,
  30. Widget loadMoreErrorBuilder(
    1. BuildContext context,
    2. Exception error,
    3. VoidCallback retry
    )?,
  31. Widget loadMoreNoMoreItemsBuilder(
    1. BuildContext context
    )?,
  32. int invisibleItemsThreshold = 3,
  33. SmartPaginationRefreshedChangeListener? refreshListener,
  34. List<SmartPaginationFilterChangeListener<T>>? filterListeners,
})

Creates a pagination widget as a ListView layout with an external Cubit

Implementation

SmartPagination.listViewWithCubit({
  super.key,
  required this.cubit,
  required this.itemBuilder,
  this.heightOfInitialLoadingAndEmptyWidget,
  this.onError,
  this.onReachedEnd,
  this.onLoaded,
  this.emptyWidget = const EmptyDisplay(),
  this.loadingWidget = const InitialLoader(),
  this.bottomLoader = const BottomLoader(),
  this.shrinkWrap = false,
  this.reverse = false,
  this.scrollDirection = Axis.vertical,
  this.padding = const EdgeInsetsGeometry.all(0),
  this.physics,
  this.scrollController,
  this.allowImplicitScrolling = false,
  this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  this.header,
  this.footer,
  this.beforeBuild,
  this.listBuilder,
  this.cacheExtent,
  Widget? separator,
  double spacing = 4,
  // State Separation Builders
  this.firstPageLoadingBuilder,
  this.firstPageErrorBuilder,
  this.firstPageEmptyBuilder,
  this.loadMoreLoadingBuilder,
  this.loadMoreErrorBuilder,
  this.loadMoreNoMoreItemsBuilder,
  // Performance Options
  this.invisibleItemsThreshold = 3,
  SmartPaginationRefreshedChangeListener? refreshListener,
  List<SmartPaginationFilterChangeListener<T>>? filterListeners,
}) : itemBuilderType = PaginateBuilderType.listView,
     gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
       crossAxisCount: 2,
     ),
     separator =
         separator ??
         (scrollDirection == Axis.horizontal
             ? SizedBox(width: spacing)
             : SizedBox(height: spacing)),
     staggeredAxisDirection = null,
     pageController = null,
     onPageChanged = null,
     customViewBuilder = null,
     onReorder = null,
     internalCubit = false,
     listeners =
         refreshListener != null || filterListeners?.isNotEmpty == true
         ? [if (refreshListener != null) refreshListener, ...?filterListeners]
         : null;