I am trying to implement snap feature to SliverPersistentHeader but couldn't figure it out and couldn't find a good documentation on this.
My code:
class MyDelegate extends SliverPersistentHeaderDelegate {
double he;
MyDelegate ({required this.he}) : super();
@override
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
return AnimatedContainer(
child: const Text('Title', textAlign: TextAlign.center, style: TextStyle(fontSize: 24),),
color: Colors.green,
height: he,
duration: const Duration(milliseconds: 100),
);
}
@override
double get maxExtent => kToolbarHeight;
@override
double get minExtent => 0;
@override
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
return true;
}
@override
FloatingHeaderSnapConfiguration get snapConfiguration => FloatingHeaderSnapConfiguration();
}
Floating is set to true.
I am getting error message for vsync being null.
I couldn't make it work. I need help on implementing snap feature for SliverPersistenHeader.