app bar dart code example

Example 1: how to make a shrinkable action bar in fluttur

Scaffold(
	body: CustomScrollView(
    	slivers: <Widget>[
        	SliverAppBar(
            	expandedHeight : 200.0,
            	floating : false,
            	pinned : true,
            	flexibleSpace : FlexibleSpaceBar(
            	//This exactly likeyour AppBar
            		title: "foo",
                	background: "Whatever you want",
            	),
           	),
            SliverFillRemaining(
            	child: //This is exactly like the body which we have for scaffold
                Center(),
            ),
            
        ],
    ),
)

Example 2: flutter appbar widget

Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('AppBar Title', textAlign: TextAlign.center),
      ),

Tags:

Misc Example