Untitled
unknown
dart
5 months ago
1.5 kB
2
Indexable
return RefreshIndicator( color: BeColus.sf.primary.default_, onRefresh: () async { widget.onRefresh?.call(controller); controller.canLoadMore = true; }, child: NotificationListener<ScrollNotification>( onNotification: (notification) { if (notification.metrics.pixels == notification.metrics.maxScrollExtent && controller.canLoadMore && controller.isLoadingMore == false) { log('scroll - load more ${controller.isLoadingMore}...'); controller.showLoadMore(); widget.onLoadMore?.call(controller).whenComplete(() { controller.completeLoadMore(); }); } return false; }, child: ListenableBuilder( listenable: controller, builder: (context, child) { final isLoadingMore = controller.isLoadingMore; final canLoadMore = controller.canLoadMore; return CustomScrollView( slivers: [ ..._buildSliversByChild(context, child!), if (isLoadingMore && canLoadMore) ...[ SliverToBoxAdapter(child: Gap(BeSpacing.s)), SliverToBoxAdapter(child: BeLoadingIndicator()), ], if (canLoadMore) ...[ SliverToBoxAdapter(child: Gap(40.scaled)), ], ], ); }, child: widget.child, ), ), );
Editor is loading...
Leave a Comment