first commit
This commit is contained in:
54
滴滴淘/ddt_flutter/lib/main.dart
Executable file
54
滴滴淘/ddt_flutter/lib/main.dart
Executable file
@@ -0,0 +1,54 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user