I'm trying to add RefreshIndicator
to CustomScrollView
. Is it possible to do? Here is the code sample:
CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('POSTAPP'),
centerTitle: true,
floating: true,
pinned: false,
),
SliverList(
delegate: SliverChildBuilderDelegate(
_createPostItem,
childCount: postRepo.posts.length,
),
),
],
);
RefreshIndicator is a widget in Flutter that supports Material's swipe-to-refresh. It works by showing a circular progress indicator when the child's Scrollable is overscrolled. If the user ends the scroll and the indicator has been dragged far enough, it will call onRefresh . You can define your own callback function.
Now lets start implementation of CustomScrollView in Flutter First of all, create a basic project and return a Custom Scroll View widget. Then, add a silver app bar and then add a silver grid. Here we only used two child widgets in the custom scroll view. The Entry point of code.
Slivers are special-purpose widgets that can be combined using a CustomScrollView to create custom scroll effects. A SliverPadding is a basic sliver that insets another sliver by applying padding on each side.
Only like this:
RefreshIndicator(child: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('POSTAPP'),
centerTitle: true,
floating: true,
pinned: false,
),
SliverList(
delegate: SliverChildBuilderDelegate(_createPostItem,
childCount: postRepo.posts.length))
],
), onRefresh: () => Future.value(true));
SliverList isn't scrollable, so you can't wrap it in RefreshIndicator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With