get<T> static method

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

Shows a CustomScrollView displaying the current state of the data list. Every item in builder must be a sliver. When scrolled at more than loadRatio, AutoListCubit.loadMore is called to fetch the next page of data

Implementation

static Widget get<T>({
  Key? key,
  SliverViewType viewType = SliverViewType.list,
  required AutoListCubit<T> cubit,
  /// whether or not the [AutoListCubit] should be disposed with this widget
  bool autoManage = true,
  Widget Function(BuildContext context, T item)? itemBuilder,
  Widget Function(BuildContext context, Widget child)? wrapper,
  Iterable<Widget> Function(BuildContext context, List<T> items)? customBuilder,
  /// 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<T> errorState)? onLoadingMoreError,
  ScrollPhysics? physics,
  bool reverse = false,
  Axis scrollDirection = Axis.vertical,
  bool shrinkWrap = false
}) {
  final listView = SliverAutoListView._(
    viewType: viewType,
    itemBuilder: itemBuilder,
    customBuilder: customBuilder,
    wrapper: wrapper,
    displayMode: DisplayMode.auto,
    loadRatio: loadRatio,
    loadingBuilder: loadingBuilder,
    loadingMoreBuilder: loadingMoreBuilder,
    emptyBuilder: emptyBuilder,
    errorBuilder: errorBuilder,
    defaultBuilder: defaultBuilder,
    onLoadingMoreError: onLoadingMoreError,
    physics: physics,
    reverse: reverse,
    scrollDirection: scrollDirection,
    shrinkWrap: shrinkWrap,
  );

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