|
...
|
...
|
@@ -46,21 +46,21 @@ import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
|
|
|
Future<bool> _requestPermissions() async {
|
|
|
|
Map<Permission, PermissionStatus> permissions = await [
|
|
|
|
Permission.photos,
|
|
|
|
Permission.location,
|
|
|
|
Permission.camera,
|
|
|
|
Permission.contacts,
|
|
|
|
Permission.storage,
|
|
|
|
Permission.notification
|
|
|
|
].request();
|
|
|
|
|
|
|
|
List<bool> results = permissions.values.toList().map((status) {
|
|
|
|
return status == PermissionStatus.granted;
|
|
|
|
}).toList();
|
|
|
|
print(results.toString());
|
|
|
|
}
|
|
|
|
// Future<bool> _requestPermissions() async {
|
|
|
|
// Map<Permission, PermissionStatus> permissions = await [
|
|
|
|
// Permission.photos,
|
|
|
|
// Permission.location,
|
|
|
|
// Permission.camera,
|
|
|
|
// Permission.contacts,
|
|
|
|
// Permission.storage,
|
|
|
|
// Permission.notification
|
|
|
|
// ].request();
|
|
|
|
|
|
|
|
// List<bool> results = permissions.values.toList().map((status) {
|
|
|
|
// return status == PermissionStatus.granted;
|
|
|
|
// }).toList();
|
|
|
|
// print(results.toString());
|
|
|
|
// }
|
|
|
|
|
|
|
|
Future<void> main() async {
|
|
|
|
FlutterBugly.postCatchedException(() async {
|
|
...
|
...
|
@@ -68,12 +68,12 @@ Future<void> main() async { |
|
|
|
FluroRouter router = FluroRouter();
|
|
|
|
Routes.configureRoutes(router);
|
|
|
|
App.router = router;
|
|
|
|
App.setupLocator();
|
|
|
|
LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
Provider.debugCheckInvalidValueType = null;
|
|
|
|
await initializeDateFormatting();
|
|
|
|
// _requestPermissions();
|
|
|
|
Utils.changeStatusColor();
|
|
|
|
// App.setupLocator();
|
|
|
|
// LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
// Provider.debugCheckInvalidValueType = null;
|
|
|
|
// await initializeDateFormatting();
|
|
|
|
// // _requestPermissions();
|
|
|
|
// Utils.changeStatusColor();
|
|
|
|
|
|
|
|
await App.initSp();
|
|
|
|
SystemChrome.setPreferredOrientations(
|
|
...
|
...
|
@@ -122,18 +122,18 @@ Future<void> main() async { |
|
|
|
));
|
|
|
|
});
|
|
|
|
// await App.initSp();
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
await AmapService.instance.init(
|
|
|
|
iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
|
|
|
// await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
// await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
// await AmapService.instance.init(
|
|
|
|
// iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
// androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
|
|
|
|
|
|
|
await AmapLocation.instance.init(
|
|
|
|
iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
);
|
|
|
|
// await AmapLocation.instance.init(
|
|
|
|
// iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
// );
|
|
|
|
|
|
|
|
/// 如果你觉得引擎的日志太多, 可以关闭Fluttify引擎的日志
|
|
|
|
await enableFluttifyLog(false); // 关闭log
|
|
|
|
// await enableFluttifyLog(false); // 关闭log
|
|
|
|
// FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
|
|
|
|
});
|
|
|
|
}
|
|
...
|
...
|
@@ -154,13 +154,13 @@ class MyAppState extends State<MyApp> { |
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
initDio();
|
|
|
|
_initFluwx();
|
|
|
|
// initDio();
|
|
|
|
// _initFluwx();
|
|
|
|
_isFirst();
|
|
|
|
Utils.changeStatusColor();
|
|
|
|
// Utils.changeStatusColor();
|
|
|
|
// 设置EasyRefresh的默认样式
|
|
|
|
EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
EasyRefresh.defaultFooter = BallPulseFooter();
|
|
|
|
// EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
// EasyRefresh.defaultFooter = BallPulseFooter();
|
|
|
|
}
|
|
|
|
|
|
|
|
//初始化微信SDK
|
|
...
|
...
|
@@ -179,7 +179,7 @@ class MyAppState extends State<MyApp> { |
|
|
|
LogUtil.v("is installed $result");
|
|
|
|
}
|
|
|
|
|
|
|
|
//初始化dio
|
|
|
|
//初始化dio
|
|
|
|
initDio() {
|
|
|
|
DioUtil.openDebug();
|
|
|
|
BaseOptions options = DioUtil.getDefOptions();
|
|
...
|
...
|
@@ -187,18 +187,46 @@ class MyAppState extends State<MyApp> { |
|
|
|
HttpConfig config = new HttpConfig(
|
|
|
|
options: options, status: "ret", code: "ret", msg: "msg", data: "data");
|
|
|
|
DioUtil().setConfig(config);
|
|
|
|
_initAmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
_initAmap() async {
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
await AmapService.instance.init(
|
|
|
|
iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
androidKey: '13464ddadd6a5d825e79f90e10ba72d2');
|
|
|
|
|
|
|
|
await AmapLocation.instance.init(
|
|
|
|
iosKey: '24fe3a700e69114a4328d4e46823dcda',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//第一次打开应用
|
|
|
|
bool _isFirst() {
|
|
|
|
_isFirst() async {
|
|
|
|
isFirst = App.sp.getBool("isFirst") ?? true;
|
|
|
|
|
|
|
|
if (!isFirst) {
|
|
|
|
_isLogin();
|
|
|
|
await _ontherInit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_ontherInit() async {
|
|
|
|
initDio();
|
|
|
|
await _initFluwx();
|
|
|
|
LogUtil.init(isDebug: true, tag: 'ONE_KEY');
|
|
|
|
Provider.debugCheckInvalidValueType = null;
|
|
|
|
await initializeDateFormatting();
|
|
|
|
|
|
|
|
// 设置EasyRefresh的默认样式
|
|
|
|
EasyRefresh.defaultHeader = MaterialHeader();
|
|
|
|
EasyRefresh.defaultFooter = BallPulseFooter();
|
|
|
|
_isLogin();
|
|
|
|
// FlutterBugly.init(androidAppId: "f71a313f42", iOSAppId: "3089e4587e");
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断是否登录
|
|
|
|
bool _isLogin() {
|
|
|
|
_isLogin() {
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
userModel.initUser();
|
|
|
|
isLogin = App.sp.getBool("isLogin") ?? false;
|
|
...
|
...
|
@@ -215,7 +243,7 @@ class MyAppState extends State<MyApp> { |
|
|
|
return MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: '一键订',
|
|
|
|
navigatorKey: App.getIt<NavigateService>().key,
|
|
|
|
// navigatorKey: App.getIt<NavigateService>().key,
|
|
|
|
theme: ThemeData(
|
|
|
|
brightness: Brightness.light,
|
|
|
|
primaryColor: Colors.white,
|
...
|
...
|
|