|
@@ -46,21 +46,21 @@ import 'package:flutter/material.dart'; |
|
@@ -46,21 +46,21 @@ import 'package:flutter/material.dart'; |
|
46
|
import 'package:flutter/services.dart';
|
46
|
import 'package:flutter/services.dart';
|
|
47
|
import 'package:permission_handler/permission_handler.dart';
|
47
|
import 'package:permission_handler/permission_handler.dart';
|
|
48
|
|
48
|
|
|
49
|
-Future<bool> _requestPermissions() async {
|
|
|
|
50
|
- Map<Permission, PermissionStatus> permissions = await [
|
|
|
|
51
|
- Permission.photos,
|
|
|
|
52
|
- Permission.location,
|
|
|
|
53
|
- Permission.camera,
|
|
|
|
54
|
- Permission.contacts,
|
|
|
|
55
|
- Permission.storage,
|
|
|
|
56
|
- Permission.notification
|
|
|
|
57
|
- ].request();
|
|
|
|
58
|
-
|
|
|
|
59
|
- List<bool> results = permissions.values.toList().map((status) {
|
|
|
|
60
|
- return status == PermissionStatus.granted;
|
|
|
|
61
|
- }).toList();
|
|
|
|
62
|
- print(results.toString());
|
|
|
|
63
|
-}
|
49
|
+// Future<bool> _requestPermissions() async {
|
|
|
|
50
|
+// Map<Permission, PermissionStatus> permissions = await [
|
|
|
|
51
|
+// Permission.photos,
|
|
|
|
52
|
+// Permission.location,
|
|
|
|
53
|
+// Permission.camera,
|
|
|
|
54
|
+// Permission.contacts,
|
|
|
|
55
|
+// Permission.storage,
|
|
|
|
56
|
+// Permission.notification
|
|
|
|
57
|
+// ].request();
|
|
|
|
58
|
+
|
|
|
|
59
|
+// List<bool> results = permissions.values.toList().map((status) {
|
|
|
|
60
|
+// return status == PermissionStatus.granted;
|
|
|
|
61
|
+// }).toList();
|
|
|
|
62
|
+// print(results.toString());
|
|
|
|
63
|
+// }
|
|
64
|
|
64
|
|
|
65
|
Future<void> main() async {
|
65
|
Future<void> main() async {
|
|
66
|
FlutterBugly.postCatchedException(() async {
|
66
|
FlutterBugly.postCatchedException(() async {
|
|
@@ -68,12 +68,12 @@ Future<void> main() async { |
|
@@ -68,12 +68,12 @@ Future<void> main() async { |
|
68
|
FluroRouter router = FluroRouter();
|
68
|
FluroRouter router = FluroRouter();
|
|
69
|
Routes.configureRoutes(router);
|
69
|
Routes.configureRoutes(router);
|
|
70
|
App.router = router;
|
70
|
App.router = router;
|
|
71
|
- App.setupLocator();
|
|
|
|
72
|
- LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
73
|
- Provider.debugCheckInvalidValueType = null;
|
|
|
|
74
|
- await initializeDateFormatting();
|
|
|
|
75
|
- // _requestPermissions();
|
|
|
|
76
|
- Utils.changeStatusColor();
|
71
|
+ // App.setupLocator();
|
|
|
|
72
|
+ // LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
73
|
+ // Provider.debugCheckInvalidValueType = null;
|
|
|
|
74
|
+ // await initializeDateFormatting();
|
|
|
|
75
|
+ // // _requestPermissions();
|
|
|
|
76
|
+ // Utils.changeStatusColor();
|
|
77
|
|
77
|
|
|
78
|
await App.initSp();
|
78
|
await App.initSp();
|
|
79
|
SystemChrome.setPreferredOrientations(
|
79
|
SystemChrome.setPreferredOrientations(
|
|
@@ -122,18 +122,18 @@ Future<void> main() async { |
|
@@ -122,18 +122,18 @@ Future<void> main() async { |
|
122
|
));
|
122
|
));
|
|
123
|
});
|
123
|
});
|
|
124
|
// await App.initSp();
|
124
|
// await App.initSp();
|
|
125
|
- await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
126
|
- await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
127
|
- await AmapService.instance.init(
|
|
|
|
128
|
- iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
129
|
- androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
125
|
+ // await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
126
|
+ // await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
127
|
+ // await AmapService.instance.init(
|
|
|
|
128
|
+ // iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
129
|
+ // androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
|
130
|
|
130
|
|
|
131
|
- await AmapLocation.instance.init(
|
|
|
|
132
|
- iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
133
|
- );
|
131
|
+ // await AmapLocation.instance.init(
|
|
|
|
132
|
+ // iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
133
|
+ // );
|
|
134
|
|
134
|
|
|
135
|
/// 如果你觉得引擎的日志太多, 可以关闭Fluttify引擎的日志
|
135
|
/// 如果你觉得引擎的日志太多, 可以关闭Fluttify引擎的日志
|
|
136
|
- await enableFluttifyLog(false); // 关闭log
|
136
|
+ // await enableFluttifyLog(false); // 关闭log
|
|
137
|
// FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
|
137
|
// FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
|
|
138
|
});
|
138
|
});
|
|
139
|
}
|
139
|
}
|
|
@@ -154,13 +154,13 @@ class MyAppState extends State<MyApp> { |
|
@@ -154,13 +154,13 @@ class MyAppState extends State<MyApp> { |
|
154
|
void initState() {
|
154
|
void initState() {
|
|
155
|
// TODO: implement initState
|
155
|
// TODO: implement initState
|
|
156
|
super.initState();
|
156
|
super.initState();
|
|
157
|
- initDio();
|
|
|
|
158
|
- _initFluwx();
|
157
|
+ // initDio();
|
|
|
|
158
|
+ // _initFluwx();
|
|
159
|
_isFirst();
|
159
|
_isFirst();
|
|
160
|
- Utils.changeStatusColor();
|
160
|
+ // Utils.changeStatusColor();
|
|
161
|
// 设置EasyRefresh的默认样式
|
161
|
// 设置EasyRefresh的默认样式
|
|
162
|
- EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
163
|
- EasyRefresh.defaultFooter = BallPulseFooter();
|
162
|
+ // EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
163
|
+ // EasyRefresh.defaultFooter = BallPulseFooter();
|
|
164
|
}
|
164
|
}
|
|
165
|
|
165
|
|
|
166
|
//初始化微信SDK
|
166
|
//初始化微信SDK
|
|
@@ -179,7 +179,7 @@ class MyAppState extends State<MyApp> { |
|
@@ -179,7 +179,7 @@ class MyAppState extends State<MyApp> { |
|
179
|
LogUtil.v("is installed $result");
|
179
|
LogUtil.v("is installed $result");
|
|
180
|
}
|
180
|
}
|
|
181
|
|
181
|
|
|
182
|
-//初始化dio
|
182
|
+ //初始化dio
|
|
183
|
initDio() {
|
183
|
initDio() {
|
|
184
|
DioUtil.openDebug();
|
184
|
DioUtil.openDebug();
|
|
185
|
BaseOptions options = DioUtil.getDefOptions();
|
185
|
BaseOptions options = DioUtil.getDefOptions();
|
|
@@ -187,18 +187,46 @@ class MyAppState extends State<MyApp> { |
|
@@ -187,18 +187,46 @@ class MyAppState extends State<MyApp> { |
|
187
|
HttpConfig config = new HttpConfig(
|
187
|
HttpConfig config = new HttpConfig(
|
|
188
|
options: options, status: "ret", code: "ret", msg: "msg", data: "data");
|
188
|
options: options, status: "ret", code: "ret", msg: "msg", data: "data");
|
|
189
|
DioUtil().setConfig(config);
|
189
|
DioUtil().setConfig(config);
|
|
|
|
190
|
+ _initAmap();
|
|
|
|
191
|
+ }
|
|
|
|
192
|
+
|
|
|
|
193
|
+ _initAmap() async {
|
|
|
|
194
|
+ await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
195
|
+ await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
196
|
+ await AmapService.instance.init(
|
|
|
|
197
|
+ iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
198
|
+ androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
|
|
|
199
|
+
|
|
|
|
200
|
+ await AmapLocation.instance.init(
|
|
|
|
201
|
+ iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
202
|
+ );
|
|
190
|
}
|
203
|
}
|
|
191
|
|
204
|
|
|
192
|
//第一次打开应用
|
205
|
//第一次打开应用
|
|
193
|
- bool _isFirst() {
|
206
|
+ _isFirst() async {
|
|
194
|
isFirst = App.sp.getBool("isFirst") ?? true;
|
207
|
isFirst = App.sp.getBool("isFirst") ?? true;
|
|
|
|
208
|
+
|
|
195
|
if (!isFirst) {
|
209
|
if (!isFirst) {
|
|
196
|
- _isLogin();
|
210
|
+ await _ontherInit();
|
|
197
|
}
|
211
|
}
|
|
198
|
}
|
212
|
}
|
|
199
|
|
213
|
|
|
|
|
214
|
+ _ontherInit() async {
|
|
|
|
215
|
+ initDio();
|
|
|
|
216
|
+ await _initFluwx();
|
|
|
|
217
|
+ LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
218
|
+ Provider.debugCheckInvalidValueType = null;
|
|
|
|
219
|
+ await initializeDateFormatting();
|
|
|
|
220
|
+
|
|
|
|
221
|
+ // 设置EasyRefresh的默认样式
|
|
|
|
222
|
+ EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
223
|
+ EasyRefresh.defaultFooter = BallPulseFooter();
|
|
|
|
224
|
+ _isLogin();
|
|
|
|
225
|
+ // FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
|
|
|
|
226
|
+ }
|
|
|
|
227
|
+
|
|
200
|
//判断是否登录
|
228
|
//判断是否登录
|
|
201
|
- bool _isLogin() {
|
229
|
+ _isLogin() {
|
|
202
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
230
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
203
|
userModel.initUser();
|
231
|
userModel.initUser();
|
|
204
|
isLogin = App.sp.getBool("isLogin") ?? false;
|
232
|
isLogin = App.sp.getBool("isLogin") ?? false;
|
|
@@ -215,7 +243,7 @@ class MyAppState extends State<MyApp> { |
|
@@ -215,7 +243,7 @@ class MyAppState extends State<MyApp> { |
|
215
|
return MaterialApp(
|
243
|
return MaterialApp(
|
|
216
|
debugShowCheckedModeBanner: false,
|
244
|
debugShowCheckedModeBanner: false,
|
|
217
|
title: '一键订',
|
245
|
title: '一键订',
|
|
218
|
- navigatorKey: App.getIt<NavigateService>().key,
|
246
|
+ // navigatorKey: App.getIt<NavigateService>().key,
|
|
219
|
theme: ThemeData(
|
247
|
theme: ThemeData(
|
|
220
|
brightness: Brightness.light,
|
248
|
brightness: Brightness.light,
|
|
221
|
primaryColor: Colors.white,
|
249
|
primaryColor: Colors.white,
|