diff --git a/CHANGELOG.md b/CHANGELOG.md index 3362150..35b0735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [4.6.1] + +- Fix empty state. + ## [4.6.0] - Refactored LoadableList & PaginatedeLoadableList constructors signature diff --git a/lib/src/loadable/loadable_list_view.dart b/lib/src/loadable/loadable_list_view.dart index b2e8261..5764d95 100644 --- a/lib/src/loadable/loadable_list_view.dart +++ b/lib/src/loadable/loadable_list_view.dart @@ -42,6 +42,8 @@ class LoadableListView extends StatefulWidget { class LoadableListViewState extends State { LoadableListViewModel get viewModel => widget.viewModel; + int get actualItemsCount => viewModel.itemCount; + @override void initState() { super.initState(); @@ -111,7 +113,7 @@ class LoadableListViewState extends State { sliver: SliverList( delegate: SliverChildBuilderDelegate( sliverDelegateBuilder, - childCount: _computeActualChildCount(viewModel.itemCount), + childCount: _computeActualChildCount(actualItemsCount), ), ), ), diff --git a/lib/src/loadable/loadable_paginated_list_view.dart b/lib/src/loadable/loadable_paginated_list_view.dart index f72787c..ee8f1f5 100644 --- a/lib/src/loadable/loadable_paginated_list_view.dart +++ b/lib/src/loadable/loadable_paginated_list_view.dart @@ -26,9 +26,12 @@ class LoadablePaginatedListState extends LoadableListViewState { LoadablePaginatedListViewModel get viewModel => widget.viewModel as LoadablePaginatedListViewModel; + @override + int get actualItemsCount => viewModel.itemCount + 1; + @override Widget buildListItem(int index) { - return index == viewModel.itemCount - 1 + return index == actualItemsCount - 1 // ignore: avoid-returning-widgets ? buildLastItem(viewModel.getPaginationState()) : super.buildListItem(index); @@ -85,7 +88,7 @@ class LoadablePaginatedListViewModel extends LoadableListViewModel { required super.errorWidget, required super.emptyStateWidget, required super.loadListRequestState, - required int itemCount, + required super.itemCount, required this.loadPageRequestState, required this.errorPageWidget, required this.isAllItemsLoaded, @@ -96,7 +99,7 @@ class LoadablePaginatedListViewModel extends LoadableListViewModel { super.footer, this.loadPage, super.key, - }) : super(itemCount: itemCount + 1); + }); final VoidCallback? loadPage; final Widget errorPageWidget; diff --git a/pubspec.yaml b/pubspec.yaml index 7afd122..163d376 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dash_kit_core description: The core component for DashKit that provides basic architecture components -version: 4.6.0 +version: 4.6.1 homepage: https://github.com/Dash-Kit/dash-kit-core environment: