简体   繁体   English

Flutter - AppBar 上的填充

[英]Flutter - Padding on AppBar

The app I'm developing must be in full screen mode at all times, however, the time/date must also be shown at all times, as well as a certain Hardware ID.我正在开发的应用程序必须始终处于全屏模式,但是,时间/日期也必须始终显示,以及某个硬件 ID。 We found the following way to present said information:我们找到了以下方式来呈现所述信息:

启用了调试绘制的应用程序的屏幕截图

However, as you may see above, I marked in red a Padding widget that is always above my AppBar, and we would like to remove that padding.但是,正如您在上面看到的,我用红色标记了一个始终位于我的 AppBar 上方的 Padding 小部件,我们希望删除该填充。 Is such a thing possible?这样的事情可能吗?

Below I have the code for the custom AppBar we're using.下面我有我们正在使用的自定义 AppBar 的代码。

@override
Widget build(BuildContext context) {
return PreferredSize(
  preferredSize: Size.fromHeight(45),
  child: AppBar(
    centerTitle: true,
    title: Column(
      children: <Widget>[
        Text(pageName,
          style: TextStyle(
              fontSize: pageNameFontSize
          ),
        ),
        SizedBox(
          height: 8,
        )
      ],
    ),
    actions: <Widget>[
      Column(
        crossAxisAlignment: CrossAxisAlignment.end,
        children: <Widget>[
          SizedBox(
            height: 6,
          ),
          Row(
            children: <Widget>[
              AppBarClock(
                style: TextStyle(
                    fontSize: 20
                ),
              ),
              SizedBox(
                width: 5,
              )
            ],
          ),
          Row(
            children: <Widget>[
              Text(this.trailText,
                textAlign: TextAlign.right,
              ),
              SizedBox(
                width: 5,
              )
            ],
          ),
        ],
      )
    ],
  ),
);

We are using SystemChrome.setEnabledSystemUIOverlays([]);我们正在使用SystemChrome.setEnabledSystemUIOverlays([]); to make the app full screen.使应用程序全屏显示。

That's because AppBar automatically includes a SafeArea whenever treated as primary.那是因为AppBar自动包含一个SafeArea每当被视为主要。

Just set the primary property of it to false .只需将它的primary属性设置为false

AppBar(
   primary: false,
   ...
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM