Youssef Maouche
Youssef Maouche

Reputation: 305

Sliver appbar not stretching flutter

Im so confuse why my sliverappbar doesnt stretch and zoom when I reach the top list. I following the flutter video

https://youtu.be/mSc7qFzxHDw

I tried the following code

class AppBar5 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverAppBar(
            title: Text("title"),
            expandedHeight: 200,
            stretch: true,

            flexibleSpace: FlexibleSpaceBar(
              background: Container(
                  width: MediaQuery.of(context).size.width,
                  height: 200,
                  child: Image.asset("assets/images/hot.jpg", fit: BoxFit.cover)
              ),
            )
          ),
          SliverList(
            delegate: SliverChildBuilderDelegate(
                  (_, index) => ListTile(
                title: Text("Index: $index"),
              ),
            ),
          )
        ],
      ),
    );
  }
}

Upvotes: 1

Views: 1436

Answers (2)

leo hagi
leo hagi

Reputation: 1

I hit on the same problem, and the stretch function worked when I changed the running device to Chrome to iOS simulator.

Upvotes: 0

Prashant
Prashant

Reputation: 676

Add Bouncing ScrollPhysics to CustomScrollView

CustomScrollView( 
      physics: BouncingScrollPhysics(),
      ...
),

Upvotes: 2

Related Questions