Skip to content

Instantly share code, notes, and snippets.

@Deali-Axy
Last active September 17, 2022 14:09
Show Gist options
  • Save Deali-Axy/ed2f15ba12c8e69a5158c50ec5396c66 to your computer and use it in GitHub Desktop.
Save Deali-Axy/ed2f15ba12c8e69a5158c50ec5396c66 to your computer and use it in GitHub Desktop.
Flutter 设置状态栏沉浸
void main() {
Global.init().then((value) {
runApp(MyApp());
});
if (Platform.isAndroid) {
// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。
var systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment