2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

Refresh fix (#436)

* Add notificationPredicate to improve scroll-to-reload

Ref: https://api.flutter.dev/flutter/material/RefreshIndicator-class.html

* Add scroll-to-refresh for paginated list
This commit is contained in:
Oliver
2023-10-23 21:59:05 +11:00
committed by GitHub
parent 8f1cd1cae1
commit b6ab9d5da5
3 changed files with 45 additions and 25 deletions

View File

@ -394,31 +394,36 @@ abstract class PaginatedSearchState<T extends PaginatedSearchWidget> extends Sta
children.add(
Expanded(
child: CustomScrollView(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.vertical,
slivers: <Widget>[
PagedSliverList.separated(
pagingController: _pagingController,
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
itemBuilder: (ctx, item, index) {
return buildItem(ctx, item);
},
noItemsFoundIndicatorBuilder: (context) {
return NoResultsWidget(noResultsText);
}
),
separatorBuilder: (context, item) => const Divider(height: .1),
)
]
child: CustomScrollView(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
scrollDirection: Axis.vertical,
slivers: <Widget>[
PagedSliverList.separated(
pagingController: _pagingController,
builderDelegate: PagedChildBuilderDelegate<InvenTreeModel>(
itemBuilder: (ctx, item, index) {
return buildItem(ctx, item);
},
noItemsFoundIndicatorBuilder: (context) {
return NoResultsWidget(noResultsText);
}
),
separatorBuilder: (context, item) => const Divider(height: 1),
)
]
)
)
)
);
return Column(
return RefreshIndicator(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: children,
),
onRefresh: () async {
_pagingController.refresh();
},
);
}