flutter - AnnotatedRegion 在真实设备上不起作用
问题描述
我使用AnnotatedRegion
小部件来更改 iOS 设备上状态栏项目的位置dark
或light
通过设置来更改,SystemUiOverlayStyle
当我在 iOS 模拟器上运行它时,它可以工作。
但遗憾的是我也尝试在真实设备上运行它,这是预览(iPhone XR)
我从新项目中制作了这个,这是我使用的代码:
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
bool _toggled = false;
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: _toggled ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
child: Container(
color: Colors.blueAccent,
child: FlatButton(
child: Text('Toggle SystemUiOverlayStyle'),
onPressed: () {
setState(() => _toggled = !_toggled);
},
),
),
);
}
}
• Flutter version 1.12.13+hotfix.8 at /Users/mochamadluckypradana/Documents/flutter
• Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
这是错误还是什么?谢谢
解决方案
在当前不稳定版本的颤振中修复(v1.16.2-pre.41)。Github 问题https://github.com/flutter/flutter/issues/53034
推荐阅读
- python - 如何使用python openpyxl删除公式并仅在单元格中保留值?
- xcode - 当我只有来自 make 输出的可执行文件时,如何创建 {ApplicationName}.app 包?
- visual-studio-code - 基于文件名的 VSCode 快捷方式
- java - 使用 java stringbuilder 的回文
- spring - 将弹簧迁移到弹簧引导控制器不起作用
- javascript - 为什么所有 redux reducer 函数都在运行时执行?
- python - Keras 中的回调异常 - Tensorflow 2.0 - Python
- c# - 使用 linq 获取具有特定对象属性的列表的一部分
- java - 如何将数据保存到房间?
- firebase - 使用 firestore 文档快照侦听器进行本地打印