Home > Software design >  how to make Silver App Should Not Collapse
how to make Silver App Should Not Collapse

Time:02-14

i want to make my silver App bar not to collapse even if i scroll up. is there a way not to make it not to collapse?

NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[
            SliverOverlapAbsorber(
              handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
              sliver: SliverAppBar(
                pinned: true,
                floating: false,
                stretch: false,
                expandedHeight: 300.0,
                flexibleSpace: FlexibleSpaceBar(
                  centerTitle: true,
                  title: const Text('Weather Report'),
                  background: Image.asset(
                    'assets/newEvent.png',
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            ),
          ];
        },

CodePudding user response:

Try this @Gbenga B Ayannuga

 NestedScrollView(
            headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
              return <Widget>[
                SliverOverlapAbsorber(
                  handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
                  sliver: SliverAppBar(
                    pinned: true,
                    floating: false,
                    stretch: false,
                    expandedHeight: 300,
      collapsedHeight: 300,
                    flexibleSpace: FlexibleSpaceBar(
                      centerTitle: true,
                      title: const Text('Weather Report'),
                      background: Image.asset(
                        'assets/newEvent.png',
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ),
              ];
            },

CodePudding user response:

Just give your SliverAppBar the same collapsedHeight as expandedHeight

SliverAppBar(
      expandedHeight: 300,
      collapsedHeight: 300,
...
)
  • Related