get<T> static method

Widget get<T>({
  1. Key? key,
  2. ViewType viewType = ViewType.list,
  3. required AutoListCubit<T> cubit,
  4. bool autoManage = true,
  5. ScrollController? scrollController,
  6. Widget itemBuilder(
    1. BuildContext context,
    2. T item
    )?,
  7. Widget separatorBuilder(
    1. BuildContext context,
    2. int index
    )?,
  8. Widget wrapper(
    1. BuildContext context,
    2. Widget child
    )?,
  9. Widget customBuilder(
    1. BuildContext context,
    2. List<T> items
    )?,
  10. SliverGridDelegate? gridDelegate,
  11. double loadRatio = 0.8,
  12. WidgetBuilder? loadingBuilder,
  13. WidgetBuilder? loadingMoreBuilder,
  14. WidgetBuilder? emptyBuilder,
  15. Widget errorBuilder(
    1. BuildContext context,
    2. VoidCallback retry
    )?,
  16. Widget defaultBuilder(
    1. BuildContext context,
    2. AutoListState<T> state
    )?,
  17. dynamic onLoadingMoreError(
    1. BuildContext context,
    2. AutoListErrorState errorState
    )?,
  18. EdgeInsets? padding,
  19. ScrollPhysics? physics,
  20. bool reverse = false,
  21. Axis scrollDirection = Axis.vertical,
  22. bool shrinkWrap = false,
})

Shows a ListView or a GridView displaying the current state of the data list. When scrolled at more than loadRatio, AutoListCubit.loadMore is called to fetch the next page of data

Implementation

static Widget get<T>({
  Key? key,
  ViewType viewType = ViewType.list,
  required AutoListCubit<T> cubit,
  /// whether or not the [AutoListCubit] should be disposed with this widget
  bool autoManage = true,
  ScrollController? scrollController,
  Widget Function(BuildContext context, T item)? itemBuilder,
  Widget Function(BuildContext context, int index)? separatorBuilder,
  Widget Function(BuildContext context, Widget child)? wrapper,
  Widget Function(BuildContext context, List<T> items)? customBuilder,
  /// grid delegate to display the list as a grid
  SliverGridDelegate? gridDelegate,
  /// the threshold percentage of the list (of the [ScrollView]'s max extent)
  /// at which the next page of data is loaded
  double loadRatio = 0.8,
  WidgetBuilder? loadingBuilder,
  WidgetBuilder? loadingMoreBuilder,
  WidgetBuilder? emptyBuilder,
  Widget Function(BuildContext context, VoidCallback retry)? errorBuilder,
  Widget Function(BuildContext context, AutoListState<T> state)? defaultBuilder,
  Function(BuildContext context, AutoListErrorState errorState)? onLoadingMoreError,
  EdgeInsets? padding,
  ScrollPhysics? physics,
  bool reverse = false,
  Axis scrollDirection = Axis.vertical,
  bool shrinkWrap = false,
}) {
  final listView = AutoListView._(
    viewType: viewType,
    scrollController: scrollController,
    itemBuilder: itemBuilder,
    separatorBuilder: separatorBuilder,
    wrapper: wrapper,
    customBuilder: customBuilder,
    displayMode: DisplayMode.auto,
    loadRatio: loadRatio,
    loadingBuilder: loadingBuilder,
    loadingMoreBuilder: loadingMoreBuilder,
    emptyBuilder: emptyBuilder,
    errorBuilder: errorBuilder,
    defaultBuilder: defaultBuilder,
    onLoadingMoreError: onLoadingMoreError,
    padding: padding,
    physics: physics,
    reverse: reverse,
    scrollDirection: scrollDirection,
    shrinkWrap: shrinkWrap,
    gridDelegate: gridDelegate,
  );

  return _init(key, autoManage, cubit, listView);
}