Flutter: Setting the height of the AppBar

Buğra Ekuklu picture Buğra Ekuklu · Jun 28, 2018 · Viewed 88.2k times · Source

How can I simply set the height of the AppBar in Flutter?

The title of the bar should be staying centered vertically (in that AppBar).

Answer

Cinn picture Cinn · Jul 21, 2018

You can use PreferredSize:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example',
      home: Scaffold(
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(50.0), // here the desired height
          child: AppBar(
            // ...
          )
        ),
        body: // ...
      )
    );
  }
}