如何在 Flutter 中更改状态栏颜色? [英] How to change status bar color in Flutter?
本文介绍了如何在 Flutter 中更改状态栏颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将状态栏颜色更改为白色.我在 flutter 上找到了 this pub.我尝试在我的 dart 文件中使用示例代码.
I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files.
推荐答案
在我的应用中完全正常
import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
FlutterStatusbarcolor.setStatusBarColor(Colors.white);
return MaterialApp(
title: app_title,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(title: home_title),
);
}
}
(这个包)
UPD:另一个解决方案
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
这篇关于如何在 Flutter 中更改状态栏颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文