SliverAppBar (Flutter Widget of the Week)

Flutter · 160K views · 2020 · 1:12

Open on YouTube

Web developmentSoftware (other)UX & UI designtutorial

Why Stack Overflow recommends it

Stack Overflow users link it as the official quick reference when answering or asking how to build collapsing, stretching or expandable app bars in Flutter.

Recommended by 0 people across 0 different months, 2020 to 2023.

What it is

A 72-second episode of the Flutter team's Widget of the Week series on SliverAppBar. It shows how expandedHeight and flexibleSpace on FlexibleSpaceBar create a header that can grow, shrink and stretch at the top of a scrolling list.

What people said

Cites Umair M · 2020-11 · Stack Overflow · on “Scaling content on drag down in Flutter”

SliverAppBar [LINK] now provides this feature out of the box using the stretch property: SliverAppBar( stretch: true, // <- this flexibleSpace: FlexibleSpaceBar( background: Image.network(' [LINK] ', fit: BoxFit.cover), title: Text('Hello again, SliverAppBar'), stretchModes: <StretchMode>[ StretchMode.zoomBackground, // <- and this ], ), ); Ref: DartPad Example [LINK] [this video]

Cites AntEdote · 2022-03 · Stack Overflow · on “How to expand/collapse the AppBar like Google Calendar in Flutter?”

SliverAppBar [this video] gives you an expandable appBar that behaves great with lists. But if you just want to do it like your example I would just make it with an AnimatedContainer. bool show = false; Scaffold( body: Column( children:[ AnimatedContainer( duration: Duration(milliseconds: 300), child: Column( children:[ Row(icon, text, actions), if(show) Calender(), ]), ), Expanded(child: OtherContent()), ], ), ), _toggleCalender(){ setState(( show = !show; )); }

Cites Youssef Maouche · 2022-05 · Stack Overflow · on “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 [this video] 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"), ), ), ) ], ), ); } }

Cites Ben the Border · 2023-06 · Stack Overflow · on “Make collapsible profile screen which pins profile picture to appbar”

The widget you need to use is SliverAppBar . You can checkout these references: Flutter's Introduction: [this video] SliverAppBar class: [LINK] FlexibleSpaceBar class: [LINK] Custom SliverAppBar: Custom Sliver App Bar in flutter with an Image and 2 Text widgets going into app bar on scrolling [LINK]