letsar / flutter_sticky_header

Flutter implementation of sticky headers for sliver
MIT License
903 stars 171 forks source link

scrollPercentage only 0 or 1 #56

Open mwinfomatica opened 3 years ago

mwinfomatica commented 3 years ago

My scrollPercentage gets only 0 or 1.

%Cblue class Body extends StatelessWidget {

@override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: CustomScrollView( slivers: [ SliverStickyHeader.builder( builder: (context, state) => Container( height: 60.0, color: (state.isPinned ? Colors.pink : Colors.lightBlue) .withOpacity(1.0 - state.scrollPercentage), padding: EdgeInsets.symmetric(horizontal: 16.0), alignment: Alignment.centerLeft, child: Text( 'Header #1', style: const TextStyle(color: Colors.white), ), ), sliver: SliverList( delegate: SliverChildBuilderDelegate( (context, i) => ListTile( leading: CircleAvatar( child: Text('0'), ), title: Text('List tile #$i'), ), childCount: 4, ), ), ), ], ), ), ); } }

letsar commented 2 years ago

If you look at the example, it varies from 0 to 1. Can you provide a complete example I could just copy/paste and run to test?