0

I have a sliverAppBar with an expandedHeight of 250. My floating is true and pinned is false. Everything works fine and dandy when I scroll down... the appbar disappears, however when i scroll up the whole sliver appears with the expandedHeight of 250.

Is there any way to make it only show the shrinked appBar height when I scroll up? My definition of the shrinked appBar is the height of the appBar when you scroll down with pinned = true.

Thanks

For reference, my code:

      SliverAppBar(
        leading: IconButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            icon: Icon(Icons.arrow_back_ios, color: Colors.grey)),
        elevation: 1,
        backgroundColor: Colors.white,
        expandedHeight: 250,
        floating: true,
        pinned: false,
        flexibleSpace: FlexibleSpaceBar(
          background: Image.network(
'https://postmediacanoe.files.wordpress.com/2019/07/gettyimages-910314172-e1564420108411.jpg',
              fit: BoxFit.cover,
              height: 250,
              width: MediaQuery.of(context).size.width),
        ),
      ),
wei
  • 557
  • 1
  • 10
  • 24
  • sorry I misread the issue. I think for this you'll need to create a SliverPersistentHeader with your own SliverPersistentHeaderDelegate. – Adrian Murray Oct 15 '19 at 19:49
  • thanks, i didn't know about the sliverPersistentHeader. I'll take a look into it – wei Oct 15 '19 at 21:22
  • That's what the SliverAppBar is. So if you go into the code of the SliverAppBar you can copy it into your own class and modify what you need. I did not try it out myself, but in the _SliverAppBarDelegate the property you'll likely want to modify is : final double visibleMainHeight = maxExtent - shrinkOffset - topPadding; Change the maxExtent to your shrunken down height and that ought to do the trick. I do wish we had a way to extend classes while overriding private portions. – Adrian Murray Oct 15 '19 at 21:39

0 Answers0