How to hide Android StatusBar in Flutter

后端 未结 10 1434
遥遥无期
遥遥无期 2020-12-01 03:22

How to hide the Android Status Bar in a Flutter App?

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-01 03:54

    This comment from Jonah Williams might be helpful in some situations as well https://github.com/flutter/flutter/issues/24472#issuecomment-440015464 if you don't want the status bar color be overridden by the AppBar.

    You cannot provide a status bar color to the app bar, but you can create your own annotated region. It's not very intuitive right now, but you can use sized: false to override the child annotated region created by the app bar.

    Somewhere, perhaps as a child of the scaffold:

    Scaffold(
      body: AnnotatedRegion(
        value: const SystemUiOverlayStyle(...),
        sized: false,
        child: ...
      )
    );
    

    Note that not all Android versions support status bar color or icon brightness. See the documentation on SystemUiOverlayStyle for the caveats.

提交回复
热议问题