peng8350 / flutter_pulltorefresh

a widget provided to the flutter scroll component drop-down refresh and pull up load.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

smart refresher doesn't work on GroupListView

abdulkash opened this issue · comments

Here is the code
SmartRefresher(
controller: controller,
enablePullDown: true,
enablePullUp: true,
physics: const AlwaysScrollableScrollPhysics(),
onRefresh: () async {
await ref.read(transactionsProvider.notifier).refreshTransactions(page: page);
controller.refreshCompleted();
},
footer: CustomFooter(builder: (_, mode) {
switch (mode) {
case LoadStatus.idle:
return const SizedBox(
height: 55.0,
child: Center(
child: Text("pull up load"),
),
);
case LoadStatus.loading:
return const SizedBox(
height: 55.0,
child: Center(
child: CupertinoActivityIndicator(),
),
);
case LoadStatus.failed:
return const SizedBox(
height: 55.0,
child: Center(
child: Text('Failed to load transactions'),
),
);
case LoadStatus.canLoading:
return const SizedBox(
height: 55.0,
child: Center(
child: Text('Release to load more'),
),
);
default:
return const SizedBox(
height: 55.0,
child: Center(
child: Text('No more data'),
),
);
}
}),
onLoading: _onLoading,
child: GroupedListView<TransactionItemEntity, DateTime>(
physics: const AlwaysScrollableScrollPhysics(),
elements: data.data.data,
groupBy: (element) => DateTime(
element.createdAt.year,
element.createdAt.month,
element.createdAt.day,
),
groupSeparatorBuilder: (groupByValue) => Padding(
padding: const EdgeInsets.only(left: 0, bottom: 15, top: 15),
child: Text(
ref.watch(transactionsProvider.notifier).checkDate(groupByValue),
style: Theme.of(context).textTheme.bodyLarge,
),
),
itemBuilder: (context, element) {
return TransactionItem(
entity: element,
);
},
useStickyGroupSeparators: false, // optional
floatingHeader: false, // optional
order: GroupedListOrder.DESC, // optional
),
),