Sliver appbar not stretching flutter

1k views Asked by At

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"),
              ),
            ),
          )
        ],
      ),
    );
  }
}
2

There are 2 answers

0
Prashant On BEST ANSWER

Add Bouncing ScrollPhysics to CustomScrollView

CustomScrollView( 
      physics: BouncingScrollPhysics(),
      ...
),
0
leo hagi On

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