magicsound/lib/main.dart
2024-08-06 16:58:12 +08:00

61 lines
1.7 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:magicsound/home_page.dart';
import 'common/Global.dart';
Future<void> main() async {
await runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
Global.initialize().then((e) {
Global();
runApp(const MyApp());
if (Platform.isAndroid) {
// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后是为了在渲染后进行set赋值覆盖状态栏写在渲染之前MaterialApp组件会覆盖掉这个值。
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
});
}, (error, stackTrace) {
print("error==$error");
});
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
// TODO: implement initState
super.initState();
//白色
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '妙创音乐',
home: const HomePage(),
//注册路由
routes: <String, WidgetBuilder>{
// '/HomePage': (BuildContext context) => const HomePage(),
},
debugShowMaterialGrid: false,
//显示网格
debugShowCheckedModeBanner: false,
//去掉右上角的debug
builder: EasyLoading.init(),
);
}
}