简体   繁体   中英

AnnotatedRegion doesn't work on real device

I use AnnotatedRegion widget to change where status bar items on iOS device should be dark or light by setting SystemUiOverlayStyle and this works when I run it on iOS Simulator.

Here's the preview (on iOS Simulator, iPhone 11): iOS模拟器预览

But sadly I also tried to run it on real device, and here's the preview (iPhone XR) 真机预览

I made this from fresh project and here's the code I use:

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

Is this bug or something? Thank you

Fixed in current unstable version of flutter (v1.16.2-pre.41). Github issue https://github.com/flutter/flutter/issues/53034

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM