Flutter - AppBar 上的填充

lui*_*els 8 user-interface android dart flutter

我正在开发的应用程序必须始终处于全屏模式,但是,时间/日期以及特定的硬件 ID 也必须始终显示。我们发现以下方式来呈现所述信息:

打开调试绘制的应用程序的屏幕截图

但是,正如您在上面看到的,我用红色标记了一个始终位于 AppBar 上方的 Padding 小部件,我们希望删除该填充。这样的事可能吗?

下面是我们正在使用的自定义 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,
              )
            ],
          ),
        ],
      )
    ],
  ),
);
Run Code Online (Sandbox Code Playgroud)

我们正在使用SystemChrome.setEnabledSystemUIOverlays([]); 使应用程序全屏显示。

Mig*_*ivo 10

那是因为AppBar自动包含一个SafeArea每当被视为主要的。

只需将primary其属性设置为即可false

AppBar(
   primary: false,
   ...
)
Run Code Online (Sandbox Code Playgroud)