首页 > 解决方案 > 颤振自定义appbar相对于状态栏的垂直位置

问题描述

我使用以下链接中的示例来创建自定义 appBar。

该代码有效,但应用栏位于 Android 状态栏后面的屏幕顶部

如何定位 appBar 以使其在状态栏下开始呈现?

使用的版本:

标签: flutterflutter-layoutflutter-appbar

解决方案


有一个名为SafeArea的小部件可以设置小部件的填充以避免状态栏的侵入。您可以将其用作:

// Use the SafeArea here to position the AppBar under the status bar
SafeArea( 
   child: Scaffold(
      appBar: PreferredSize(
        preferredSize: Size(double.infinity, 100),
        child: Container(
          decoration: BoxDecoration(

          // ... other lines

推荐阅读