From 4e7c96f3931237073664819e4d03e4f826a71070 Mon Sep 17 00:00:00 2001 From: datang Date: Mon, 9 May 2022 17:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../geographic_information_page.dart | 24 +++++++++++++++++-- lib/pages/one_alarm/widget/alarm_page.dart | 5 +++- lib/pages/splash/splash_page.dart | 8 +++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/pages/geographic_information/geographic_information_page.dart b/lib/pages/geographic_information/geographic_information_page.dart index 1437da76..4558e3b5 100644 --- a/lib/pages/geographic_information/geographic_information_page.dart +++ b/lib/pages/geographic_information/geographic_information_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:aku_new_community/constants/api.dart'; import 'package:aku_new_community/pages/one_alarm/alarm_detail_page.dart'; import 'package:aku_new_community/pages/one_alarm/widget/alarm_page.dart'; @@ -6,14 +8,24 @@ import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:amap_flutter_base/amap_flutter_base.dart'; +import 'package:amap_flutter_location/amap_flutter_location.dart'; import 'package:amap_flutter_map/amap_flutter_map.dart'; +import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_icons/flutter_icons.dart'; import 'package:get/get.dart'; +import 'package:hive/hive.dart'; +import 'package:hive_flutter/adapters.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:power_logger/power_logger.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../main_initialize.dart'; +import '../../utils/hive_store.dart'; +import '../../widget/others/user_tool.dart'; + class GeographicInformationPage extends StatefulWidget { GeographicInformationPage({Key? key}) : super(key: key); @@ -28,7 +40,15 @@ class _GeographicInformationPageState extends State { @override void initState() { super.initState(); - PermissionUtil.getLocationPermission(); + Future.delayed(Duration(milliseconds: 1000), () async { + //本地存储初始化在最前 + //初始化AMap + // await AmapLocation.instance.init(iosKey: 'ios key'); + PermissionUtil.getLocationPermission(); + UserTool.appProvider.startLocation(); + }); + + } @override @@ -55,7 +75,7 @@ class _GeographicInformationPageState extends State { _mapController = controller; _mapController!.moveCamera( CameraUpdate.newCameraPosition( - CameraPosition(target: _target, zoom: 18), + CameraPosition(target: _target, zoom: 14), ), ); }, diff --git a/lib/pages/one_alarm/widget/alarm_page.dart b/lib/pages/one_alarm/widget/alarm_page.dart index 225c57f3..4e34e8e1 100644 --- a/lib/pages/one_alarm/widget/alarm_page.dart +++ b/lib/pages/one_alarm/widget/alarm_page.dart @@ -13,6 +13,8 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../../widget/others/user_tool.dart'; + class PermissionUtil { static Future getLocationPermission() async { return await Permission.locationWhenInUse.request().isGranted; @@ -37,6 +39,7 @@ class _AlarmPageState extends State { void initState() { super.initState(); PermissionUtil.getLocationPermission(); + UserTool.appProvider.startLocation(); } @override @@ -72,7 +75,7 @@ class _AlarmPageState extends State { _mapController = controller; _mapController!.moveCamera( CameraUpdate.newCameraPosition( - CameraPosition(target: _target, zoom: 18), + CameraPosition(target: _target, zoom: 14), ), ); }, diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index 9d9f03db..d373ec69 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -109,9 +109,9 @@ class _SplashPageState extends State { } //初始化AMap // await AmapLocation.instance.init(iosKey: 'ios key'); - if (Platform.isAndroid || Platform.isIOS) { - await Permission.locationWhenInUse.request(); - } + // if (Platform.isAndroid || Platform.isIOS) { + // await Permission.locationWhenInUse.request(); + // } //第三方加载 EquatableConfig.stringify = true; AMapFlutterLocation.updatePrivacyShow(true, true); @@ -119,7 +119,7 @@ class _SplashPageState extends State { MainInitialize.initTheme(); MainInitialize.initWechat(); MainInitialize.initWebSocket(); - UserTool.appProvider.startLocation(); + // UserTool.appProvider.startLocation(); UserTool.appProvider.initApplications(); //获取城市列表等信息 await UserTool.dataProvider.init();