ChatApp/lib/main.dart
2024-06-15 14:38:50 +08:00

66 lines
1.6 KiB
Dart
Raw 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 'dart:math';
import 'package:Chat/tools/HomePage.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'common/Global.dart';
Future<void> main() async {
await runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
Global.initialize().then((e) {
new Global();
runApp(ChatApp());
if (Platform.isAndroid) {
// 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后是为了在渲染后进行set赋值覆盖状态栏写在渲染之前MaterialApp组件会覆盖掉这个值。
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
});
}, (error, stackTrace) {
print("error==$error");
});
}
class ChatApp extends StatefulWidget {
const ChatApp({super.key});
@override
State<ChatApp> createState() => _ChatAppState();
}
class _ChatAppState extends State<ChatApp> {
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'AI聊天',
home: Homepage(),
//注册路由
routes: <String, WidgetBuilder>{
'/HomePage': (BuildContext context) => Homepage(),
},
debugShowMaterialGrid: false,
//显示网格
debugShowCheckedModeBanner: false,
//去掉右上角的debug
builder: EasyLoading.init(),
);
}
}