flutter - 颤振自定义appbar相对于状态栏的垂直位置
问题描述
我使用以下链接中的示例来创建自定义 appBar。
该代码有效,但应用栏位于 Android 状态栏后面的屏幕顶部
如何定位 appBar 以使其在状态栏下开始呈现?
使用的版本:
- Flutter 1.26.0-8.0.pre • 频道开发
- 安卓R30
解决方案
有一个名为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
推荐阅读
- python - 在一张图上绘制变化的函数
- python - 如何遍历列表并在python中执行多个过滤条件
- azure - 禁用的 Azure 功能仍会从 Azure 存储队列中拉出消息
- php - 一个项目可以同时使用 Firebase 和 PHP 吗?
- apache-spark - 在远程 Yarn 集群上使用 spark 从 S3 访问文件时出现问题
- reporting-services - 如何将 FetchXml (ssrs) 中的同一实体与不同的 prefilterparametername 链接?
- angular - 类型'可观察的
' 不可分配给类型 'Observable ' - javascript - 日期解析月份格式
- c++ - 如何在 QQuickView 中正确渲染透明网格
- android - 当我们从设置中手动关闭权限并返回我们的应用程序时,它会因空指针异常而崩溃