Skip to content

Commit

Permalink
return itemCount + 1 logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TimYusR committed Aug 9, 2024
1 parent 3bbbfc8 commit 3af5f79
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/src/loadable/loadable_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ class LoadableListViewState extends State<LoadableListView> {
),
),
// ignore: avoid-returning-widgets
SliverToBoxAdapter(child: buildLastItem(state)),
// ignore: avoid-returning-widgets
if (viewModel.footer != null) buildFooter(),
];
}
Expand Down
12 changes: 10 additions & 2 deletions lib/src/loadable/loadable_paginated_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -88,7 +96,7 @@ class LoadablePaginatedListViewModel extends LoadableListViewModel {
super.footer,
this.loadPage,
super.key,
});
}) : super(itemCount: itemCount + 1);

final VoidCallback? loadPage;
final Widget errorPageWidget;
Expand Down

0 comments on commit 3af5f79

Please sign in to comment.