Flutter:设置AppBar的高度 [英] Flutter: Setting the height of the AppBar

查看:2754
本文介绍了Flutter:设置AppBar的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Flutter中简单地设置AppBar的高度?

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

该栏的标题应保持垂直居中(在该AppBar中).

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

推荐答案

您可以使用 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: // ...
      )
    );
  }
}

这篇关于Flutter:设置AppBar的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆