Reputation: 147
I'm working on a flutter project, where in I want to make two widgets to be sticky on scroll.
EDIT: I have a sticky app bar, a sticky tab bar, and within the tab body, I want a sticky widget.
Upvotes: 1
Views: 1183
Reputation: 63594
You can use sliver_tools
multisliver
class WidgetThatReturnsASliver extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CustomScrollView(slivers: [
MultiSliver(
pushPinnedChildren: false, // defaults to false
children: <Widget>[
SliverPinnedHeader(
child: Text("pinnded header"),
),
SliverToBoxAdapter(
child: Container(
height: 899,
),
),
SliverPinnedHeader(
child: Text("pinnded header2"),
),
SliverToBoxAdapter(
child: Container(
height: 899,
),
),
],
),
]);
}
}
Upvotes: 1
Reputation: 1230
Do something like this
body:Column(
Children:[Sticky Widget1,
Sticky Widget2,
Expended(child:Listview(children:
[ScrollableWidget1,ScrollableWidget2,...]
))]
)
All the best!!!
Upvotes: 0