故事的开始
己亥年末 庚子春,荆楚大疫,染着数万计,九州之内皆惶恐。举国防 皆闭户。南山君镇守江南都,率白衣郎中数万抗之。且九州一心,月余 疫尽去,国泰民安。
一、状态栏
1.全局设置
import 'package:flutter/material.dart';
import 'dart:io';
import 'package:flutter/services.dart';
void main(){
runApp(MyApp());
if(Platform.isAndroid){
SystemUiOverlayStyle style = SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
///这是设置状态栏的图标和字体的颜色
///Brightness.light 一般都是显示为白色
///Brightness.dark 一般都是显示为黑色
statusBarIconBrightness: Brightness.light
);
SystemChrome.setSystemUIOverlayStyle(style);
}
}
2.单个页面设置
使用AnnotatedRegion包裹Scaffold,可以使得状态栏颜色改变,有dark和light两种
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class test extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
return Text('Body');
}
}
单页面设置未生效解决
如果要亮色设置为Brightness.dark;如果要暗色则设置为Brightness.light
Scaffold(
appBar: AppBar(brightness: Brightness.dark)
)
Scaffold(
appBar: AppBar(brightness: Brightness.light)
)
网友评论