I want the ScrollController
to animate to the body
part of the NestedScrollView
widget, when click on the summary item on the headersliver
list.
class __JobProgDtlBodyState extends State<_JobProgDtlBody> {
ScrollController controller;
@override
void initState() {
controller = ScrollController();
super.initState();
}
@override
Widget build(BuildContext context) {
return NestedScrollView(
floatHeaderSlivers: true,
controller: controller,
dragStartBehavior: DragStartBehavior.start,
headerSliverBuilder: (context, overlap) {
return [
SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 2,
mainAxisSpacing: 2,
childAspectRatio: .95,
),
delegate: SliverChildBuilderDelegate(
(context, position) {
return SummaryGridTile(
position: position,
primaryTitle: "{summary.description} ",
count:24,
isPercentage: summary.isPercentage,
primaryIcon: Icons.view_agenda,
onClick: () {
controller.animateTo(context.size.height,
duration: kThemeAnimationDuration,
curve: Curves.ease);
});
},
childCount: 10,
))
];
},
body: Stack(
fit: StackFit.expand,
children: [
Container(
margin: EdgeInsets.symmetric(horizontal: 4),
child: Column(
children: [
Expanded(
child: Container(
margin: EdgeInsets.only(top: 8, left: 4, right: 1),
padding:
EdgeInsets.symmetric(vertical: 12, horizontal: 4),
child: ListView.builder(
padding:
EdgeInsets.only(top: 14, left: 8, right: 8),
shrinkWrap: true,
itemCount:10,
itemBuilder: (context, pos) {
return SalesEnquiryListItem(
);
})),
),
],
),
),
Positioned(
child: FloatingActionButton(
child: Icon(Icons.sort),
onPressed: () {
FocusScope.of(context).requestFocus(FocusNode());
Navigator.push<dynamic>(
context,
MaterialPageRoute<dynamic>(
builder: (BuildContext context) =>
FiltersScreen(),
fullscreenDialog: false),
);
},
),
right: 8,
bottom: 8,
)
],
),
);
}
}
question from:
https://stackoverflow.com/questions/65913953/how-to-make-flutter-nestedscrollview-to-animate-to-body-part-of-the-widget 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…