Merge branch 'develop' into build-addGateway-20240814

This commit is contained in:
魏少阳 2025-01-13 17:47:17 +08:00
commit d1513c4e3a
2 changed files with 116 additions and 146 deletions

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:io';
@ -31,7 +30,9 @@ class LockAddressGaoDePage extends StatefulWidget {
class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
with RouteAware {
final LockAddressGaoDeLogic logic = Get.put(LockAddressGaoDeLogic());
final LockAddressGaoDeState state = Get.find<LockAddressGaoDeLogic>().state;
final LockAddressGaoDeState state = Get
.find<LockAddressGaoDeLogic>()
.state;
//
static AMapApiKey amapApiKeys =
@ -52,51 +53,16 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
requestPermission();
}
// Future<void> requestPermission() async {
// final status = await Permission.location.request();
// AppLog.log("Permission.location.request()=status:$status");
// permissionStatus = status;
// if(Platform.isIOS){
// _setLocationOption();
// requestIOSLocation();
// }
// switch (status) {
// case PermissionStatus.denied:
// // AppLog.log("拒绝");
// break;
// case PermissionStatus.granted:
// if(Platform.isIOS){
// // _setLocationOption();
// // requestIOSLocation();
// }else{
// requestAndroidLocation();
// location.startLocation();
// }
// break;
// case PermissionStatus.limited:
// // AppLog.log("限制");
// break;
// case PermissionStatus.permanentlyDenied:
// // AppLog.log("永久的否认");
// break;
// case PermissionStatus.provisional:
// // AppLog.log("临时");
// break;
// default:
// // AppLog.log("其他状态");
// // requestLocation();
// break;
// }
// }
Future<void> requestPermission() async {
final bool status = await PermissionDialog.request(Permission.location);
if(Platform.isIOS){
if (Platform.isIOS) {
_setLocationOption();
requestIOSLocation();
}
if (!Platform.isIOS || status) {
_setLocationOption();
requestAndroidLocation();
location.startLocation();
}
@ -114,9 +80,8 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
}
Future<void> requestIOSLocation() async {
location = AMapFlutterLocation()
..setLocationOption(AMapLocationOption())
..onLocationChanged().listen((Map<String, Object> event) {
location.setLocationOption(AMapLocationOption());
location.onLocationChanged().listen((Map<String, Object> event) {
// AppLog.log("listenLocationChanged$event");
// EasyLoading.dismiss();
if (event.isNotEmpty) {
@ -125,8 +90,8 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
});
// location.stopLocation();
}
})
..startLocation();
});
location.startLocation();
}
@override
@ -183,6 +148,9 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
onMapCreated: (AMapController controller) {
mapController = controller;
},
onLocationChanged: (AMapLocation location) {
print("onLocationChanged ${location}");
},
),
),
Container(
@ -242,7 +210,8 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
style: TextStyle(color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
Get.toNamed(Routers.addLockSelectCountryPage, arguments: <String, Object>{
Get.toNamed(Routers.addLockSelectCountryPage,
arguments: <String, Object>{
'addressInfo': {},
'pwdTimestamp': state.pwdTimestamp.value,
'lockInfo': state.lockInfo,
@ -262,7 +231,8 @@ class _LockAddressGaoDePageState extends State<LockAddressGaoDePage>
logic.showToast('还未获取到位置信息哦,请耐心等待一下!'.tr);
return;
}
Get.toNamed(Routers.saveLockPage, arguments: <String, Object?>{
Get.toNamed(Routers.saveLockPage,
arguments: <String, Object?>{
'addressInfo': addressInfo,
'pwdTimestamp': state.pwdTimestamp.value,
'lockInfo': state.lockInfo,

View File

@ -193,11 +193,11 @@ dependencies:
easy_refresh: ^3.3.4
#高德地图定位
amap_flutter_location: ^3.0.0
amap_flutter_location: 3.0.0
#权限使用
permission_handler: ^11.3.1
#高德地图地图
amap_flutter_map: ^3.0.0
amap_flutter_map: 3.0.0
# 谷歌地图
google_maps_flutter: ^2.2.5