首页 > 解决方案 > AnnotatedRegion 在真实设备上不起作用

问题描述

我使用AnnotatedRegion小部件来更改 iOS 设备上状态栏项目的位置darklight通过设置来更改,SystemUiOverlayStyle当我在 iOS 模拟器上运行它时,它可以工作。

这是预览(在 iOS 模拟器、iPhone 11 上): 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

这是错误还是什么?谢谢

标签: flutter

解决方案


在当前不稳定版本的颤振中修复(v1.16.2-pre.41)。Github 问题https://github.com/flutter/flutter/issues/53034


推荐阅读