54 lines
1.3 KiB
Dart
Executable File
54 lines
1.3 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
// 事件总控
|
|
import 'package:event_bus/event_bus.dart';
|
|
// shared_preferences 离线数据存储
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
// 主题切换事件
|
|
import 'package:flutter_app/event/themeChangeEvent.dart';
|
|
// 全局 event_bus 事件
|
|
import 'package:flutter_app/common/Application.dart';
|
|
// 启动欢迎组件
|
|
import 'package:flutter_app/view/components/WelcomeWidget.dart';
|
|
// 全局配置类
|
|
import 'package:flutter_app/config/index.dart';
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
// 主入口
|
|
void main () async {
|
|
// 获取主题,传递给初 initApp 类
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
runApp(new initApp());
|
|
}
|
|
|
|
// ignore: camel_case_types
|
|
class initApp extends StatefulWidget {
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => StartApp();
|
|
}
|
|
|
|
class StartApp extends State<initApp> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return new MaterialApp(
|
|
title: "Flutter App",
|
|
builder: BotToastInit(), //1. call BotToastInit
|
|
navigatorObservers: [BotToastNavigatorObserver()],
|
|
theme: Config.getThemeData(false),
|
|
home: WelcomeWidget(true),
|
|
routes: Config.routers,
|
|
);
|
|
}
|
|
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
Application.eventBus.destroy();
|
|
}
|
|
} |