Flutter: Setting the height of the AppBar

前端 未结 7 2122
刺人心
刺人心 2020-12-08 01:49

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).

7条回答
  •  [愿得一人]
    2020-12-08 02:37

    If you are in Visual Code, Ctrl + Click on AppBar function.

    Widget demoPage() {
      AppBar appBar = AppBar(
        title: Text('Demo'),
      );
      return Scaffold(
        appBar: appBar,
        body: /*
        page body
        */,
      );
    }
    

    And edit this piece.

    app_bar.dart will open and you can find 
        preferredSize = new Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)),
    

    Difference of height!

    sample image

    sample image

提交回复
热议问题