diff --git a/lib/src/loadable/loadable_list_view.dart b/lib/src/loadable/loadable_list_view.dart index 8bd8741..b2e8261 100644 --- a/lib/src/loadable/loadable_list_view.dart +++ b/lib/src/loadable/loadable_list_view.dart @@ -116,8 +116,6 @@ class LoadableListViewState extends State { ), ), // ignore: avoid-returning-widgets - SliverToBoxAdapter(child: buildLastItem(state)), - // ignore: avoid-returning-widgets if (viewModel.footer != null) buildFooter(), ]; } diff --git a/lib/src/loadable/loadable_paginated_list_view.dart b/lib/src/loadable/loadable_paginated_list_view.dart index 3e7db8e..f72787c 100644 --- a/lib/src/loadable/loadable_paginated_list_view.dart +++ b/lib/src/loadable/loadable_paginated_list_view.dart @@ -26,6 +26,14 @@ class LoadablePaginatedListState extends LoadableListViewState { LoadablePaginatedListViewModel get viewModel => widget.viewModel as LoadablePaginatedListViewModel; + @override + Widget buildListItem(int index) { + return index == viewModel.itemCount - 1 + // ignore: avoid-returning-widgets + ? buildLastItem(viewModel.getPaginationState()) + : super.buildListItem(index); + } + @override Widget buildFooter() { return SliverToBoxAdapter( @@ -77,7 +85,7 @@ class LoadablePaginatedListViewModel extends LoadableListViewModel { required super.errorWidget, required super.emptyStateWidget, required super.loadListRequestState, - required super.itemCount, + required int itemCount, required this.loadPageRequestState, required this.errorPageWidget, required this.isAllItemsLoaded, @@ -88,7 +96,7 @@ class LoadablePaginatedListViewModel extends LoadableListViewModel { super.footer, this.loadPage, super.key, - }); + }) : super(itemCount: itemCount + 1); final VoidCallback? loadPage; final Widget errorPageWidget;