flutter配置Android状态栏透明
开发Flutter项目中,在Android平台下让状态栏透明,如下配置:
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main () {
runApp(const MyApp());
/// 配置如下:
/// Android状态栏透明
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle =
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
MyAppState createState() => MyAppState();
}
class MyAppState extends State<MyApp> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.blueAccent,
body: SafeArea(
child: Column(
children: [
Text("测试页面"),
],
),
),
),
);
}
}