AnnotatedRegion在实际设备上不起作用

时间:2020-03-18 04:57:03

标签: flutter

我使用AnnotatedRegion小部件通过设置dark来更改iOS设备上的状态栏项目应为lightSystemUiOverlayStyle的位置,当我在iOS Simulator上运行它时,此功能可以工作

以下是预览(在iOS Simulator,iPhone 11上): iOS Simulator preview

但是不幸的是,我也尝试在真实设备上运行它,这是预览(iPhone XR) Real device preview

我是从新项目中制作的,这是我使用的代码:

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

这是bug还是什么?谢谢

1 个答案:

答案 0 :(得分:0)

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