File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## [ 1.0.6] - 29/03/2022
2+
3+ * Fixed a bug where fetchData was called twice if PaginationItemsStateHandler was used as parent in release mode (optimization).
4+ * Updated example app
5+
16## [ 1.0.5] - 29/03/2022
27
38* Added access/update to list elements by using [ ] syntax on PaginatedItemsResponse directly.
Original file line number Diff line number Diff line change @@ -14,17 +14,17 @@ class HomeScreen extends StatelessWidget {
1414
1515 @override
1616 Widget build (BuildContext context) {
17- return const PostsListWithController ();
18- // return const PostsListWithoutController ();
17+ return const PostsListWithStateHandledExternally ();
18+ // return const PostsListWithStateHandledInternally ();
1919 }
2020}
2121
2222//******************************************************************
2323// WITH CONTROLLER
2424//******************************************************************
2525
26- class PostsListWithController extends StatelessWidget {
27- const PostsListWithController ({
26+ class PostsListWithStateHandledExternally extends StatelessWidget {
27+ const PostsListWithStateHandledExternally ({
2828 Key ? key,
2929 }) : super (key: key);
3030
@@ -59,8 +59,8 @@ class PostsListWithController extends StatelessWidget {
5959// WITHOUT CONTROLLER
6060//******************************************************************
6161
62- class PostsListWithoutController extends StatelessWidget {
63- const PostsListWithoutController ({
62+ class PostsListWithStateHandledInternally extends StatelessWidget {
63+ const PostsListWithStateHandledInternally ({
6464 Key ? key,
6565 }) : super (key: key);
6666
Original file line number Diff line number Diff line change @@ -272,15 +272,9 @@ class _PaginatedItemsBuilderState<T> extends State<PaginatedItemsBuilder<T>> {
272272 ? _config? .mockItemGetter <T >()
273273 : _config? .mockItemGetter (widget.mockItemKey);
274274
275- late bool hasItemsStateHandlerAsParent;
276- context.visitAncestorElements ((element) {
277- hasItemsStateHandlerAsParent =
278- element.toStringShort ().contains ('PaginationItemsStateHandler' );
279-
280- // stop visiting any more ancestors if already found i.e. return false.
281- return ! hasItemsStateHandlerAsParent;
282- });
283- if (! hasItemsStateHandlerAsParent) _fetchData ();
275+ final itemsStateHandlerAsParent =
276+ context.findAncestorWidgetOfExactType <PaginationItemsStateHandler <T >>();
277+ if (itemsStateHandlerAsParent == null ) _fetchData ();
284278
285279 PaginatedItemsBuilder .config ?? =
286280 PaginatedItemsBuilderConfig .defaultConfig ();
Original file line number Diff line number Diff line change 11name : paginated_items_builder
22description : Easier to display items in a list/grid view from your controllers directly or handling state internally with support for pagination.
3- version : 1.0.5
3+ version : 1.0.6
44homepage : https://github.com/rithik-dev/paginated_items_builder
55
66environment :
You can’t perform that action at this time.
0 commit comments