嗨,我正在尝试更改状态栏,使其与我的应用栏颜色保持一致,但我没有运气,我试图这样做:
@override
Widget build(BuildContext context) {
return Scaffold(
body: AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(statusBarColor: Colors.black,
systemNavigationBarColor: Colors.black),
但是我的状态栏仍然像这样:
但是在iPhone上,它可以正确显示颜色
答案 0 :(得分:1)
导入
import 'package:flutter/services.dart';
并将此代码添加到主窗口小部件树中:
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.blue,
statusBarBrightness: Brightness.dark, // as you need dark or light
));
return MaterialApp(home: yourHomeWidgetWhereTheScaffoldIsDefined....
希望这会有所帮助