Compare commits
3 Commits
135caf5adc
...
ee11c80e9f
Author | SHA1 | Date |
---|---|---|
zhuce | ee11c80e9f | |
zhuce | b4908ceb4c | |
zhuce | 97128918e4 |
68
ios/Podfile
68
ios/Podfile
|
@ -37,8 +37,74 @@ target 'Runner' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
post_install do |installer|
|
post_install do |installer|
|
||||||
installer.pods_project.targets.each do |target|
|
installer.pods_project.targets.each do |target|
|
||||||
flutter_additional_ios_build_settings(target)
|
flutter_additional_ios_build_settings(target)
|
||||||
|
|
||||||
|
# Start of the permission_handler configuration
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
|
||||||
|
# You can enable the permissions needed here. For example to enable camera
|
||||||
|
# permission, just remove the `#` character in front so it looks like this:
|
||||||
|
#
|
||||||
|
# ## dart: PermissionGroup.camera
|
||||||
|
# 'PERMISSION_CAMERA=1'
|
||||||
|
#
|
||||||
|
# Preprocessor definitions can be found at: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
|
||||||
|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
|
||||||
|
'$(inherited)',
|
||||||
|
|
||||||
|
## dart: [PermissionGroup.calendarWriteOnly, PermissionGroup.calendar (iOS 16 and below)]
|
||||||
|
# 'PERMISSION_EVENTS=1',
|
||||||
|
|
||||||
|
## dart: [PermissionGroup.calendarFullAccess, PermissionGroup.calendar (iOS 17 and above)]
|
||||||
|
# 'PERMISSION_EVENTS_FULL_ACCESS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.reminders
|
||||||
|
# 'PERMISSION_REMINDERS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.contacts
|
||||||
|
# 'PERMISSION_CONTACTS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.camera
|
||||||
|
'PERMISSION_CAMERA=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.microphone
|
||||||
|
# 'PERMISSION_MICROPHONE=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.speech
|
||||||
|
# 'PERMISSION_SPEECH_RECOGNIZER=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.photos
|
||||||
|
'PERMISSION_PHOTOS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.photosAddOnly
|
||||||
|
# 'PERMISSION_PHOTOS_ADD_ONLY=1',
|
||||||
|
|
||||||
|
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
|
||||||
|
'PERMISSION_LOCATION=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.notification
|
||||||
|
'PERMISSION_NOTIFICATIONS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.mediaLibrary
|
||||||
|
# 'PERMISSION_MEDIA_LIBRARY=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.sensors
|
||||||
|
# 'PERMISSION_SENSORS=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.bluetooth
|
||||||
|
# 'PERMISSION_BLUETOOTH=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.appTrackingTransparency
|
||||||
|
# 'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
|
||||||
|
|
||||||
|
## dart: PermissionGroup.criticalAlerts
|
||||||
|
# 'PERMISSION_CRITICAL_ALERTS=1'
|
||||||
|
]
|
||||||
|
|
||||||
|
end
|
||||||
|
# End of the permission_handler configuration
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -20,6 +20,8 @@ PODS:
|
||||||
- ZXSDK
|
- ZXSDK
|
||||||
- GTSDK (3.0.5.0):
|
- GTSDK (3.0.5.0):
|
||||||
- GTCommonSDK (> 3.0.9.0)
|
- GTCommonSDK (> 3.0.9.0)
|
||||||
|
- permission_handler_apple (9.3.0):
|
||||||
|
- Flutter
|
||||||
- shared_preferences_foundation (0.0.1):
|
- shared_preferences_foundation (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
|
@ -31,6 +33,7 @@ DEPENDENCIES:
|
||||||
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
- getuiflut (from `.symlinks/plugins/getuiflut/ios`)
|
- getuiflut (from `.symlinks/plugins/getuiflut/ios`)
|
||||||
|
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
||||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
|
@ -53,6 +56,8 @@ EXTERNAL SOURCES:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
getuiflut:
|
getuiflut:
|
||||||
:path: ".symlinks/plugins/getuiflut/ios"
|
:path: ".symlinks/plugins/getuiflut/ios"
|
||||||
|
permission_handler_apple:
|
||||||
|
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||||
|
|
||||||
|
@ -67,9 +72,10 @@ SPEC CHECKSUMS:
|
||||||
getuiflut: 8628ba2b64a738a847a07d2b67e0ac305778e2ee
|
getuiflut: 8628ba2b64a738a847a07d2b67e0ac305778e2ee
|
||||||
GTCommonSDK: 2be8c2d5b094929f81b64dba8767bf110bae78de
|
GTCommonSDK: 2be8c2d5b094929f81b64dba8767bf110bae78de
|
||||||
GTSDK: cc04d169c5c6cb8f8884849153eaac9e6ccfdd7c
|
GTSDK: cc04d169c5c6cb8f8884849153eaac9e6ccfdd7c
|
||||||
|
permission_handler_apple: 036b856153a2b1f61f21030ff725f3e6fece2b78
|
||||||
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
|
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
|
||||||
ZXSDK: 414bed508b670437a9bdf7c75d49816b8cb7b2d4
|
ZXSDK: 414bed508b670437a9bdf7c75d49816b8cb7b2d4
|
||||||
|
|
||||||
PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
|
PODFILE CHECKSUM: b2ff02a7210c740947b0635c5db14e8d36382e1f
|
||||||
|
|
||||||
COCOAPODS: 1.15.2
|
COCOAPODS: 1.15.2
|
||||||
|
|
|
@ -45,5 +45,13 @@
|
||||||
<true/>
|
<true/>
|
||||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
|
||||||
|
<string>需要使用您的定位,地图附近显示停车、车辆信息</string>
|
||||||
|
<key>NSLocationAlwaysUsageDescription</key>
|
||||||
|
<string>需要使用您的定位,地图附近显示停车、车辆信息</string>
|
||||||
|
<key>NSLocationUsageDescription</key>
|
||||||
|
<string>需要使用您的定位,地图附近显示停车、车辆信息</string>
|
||||||
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
|
<string>需要使用您的定位,地图附近显示停车、车辆信息</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -2,13 +2,16 @@ import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||||
|
|
||||||
class ConstConfig {
|
class ConstConfig {
|
||||||
|
|
||||||
|
static const String androidKey='c715f41c63e5bd7faef2b53de7438709';
|
||||||
|
static const String iosKey='8c545f5186ddd9d2c585693f72b4790a';
|
||||||
///配置您申请的apikey,在此处配置之后,可以在初始化[AMapWidget]时,通过`apiKey`属性设置
|
///配置您申请的apikey,在此处配置之后,可以在初始化[AMapWidget]时,通过`apiKey`属性设置
|
||||||
///
|
///
|
||||||
///注意:使用[AMapWidget]的`apiKey`属性设置的key的优先级高于通过Native配置key的优先级,
|
///注意:使用[AMapWidget]的`apiKey`属性设置的key的优先级高于通过Native配置key的优先级,
|
||||||
///使用[AMapWidget]的`apiKey`属性配置后Native配置的key将失效,请根据实际情况选择使用
|
///使用[AMapWidget]的`apiKey`属性配置后Native配置的key将失效,请根据实际情况选择使用
|
||||||
static const AMapApiKey amapApiKeys = AMapApiKey(
|
static const AMapApiKey amapApiKeys = AMapApiKey(
|
||||||
androidKey: 'c715f41c63e5bd7faef2b53de7438709',
|
androidKey: androidKey,
|
||||||
iosKey: '8c545f5186ddd9d2c585693f72b4790a');
|
iosKey: iosKey);
|
||||||
|
|
||||||
///高德隐私合规声明,这里只是示例,实际使用中请按照实际参数设置[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数
|
///高德隐私合规声明,这里只是示例,实际使用中请按照实际参数设置[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
import 'package:autosos_flutter/config/theme_colors.dart';
|
||||||
import 'package:autosos_flutter/const_config.dart';
|
|
||||||
import 'package:autosos_flutter/pages/home/widgets/image_block.dart';
|
import 'package:autosos_flutter/pages/home/widgets/image_block.dart';
|
||||||
|
import 'package:autosos_flutter/pages/home/widgets/map_widget.dart';
|
||||||
import 'package:autosos_flutter/pages/home/widgets/number_block.dart';
|
import 'package:autosos_flutter/pages/home/widgets/number_block.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../config/theme_colors.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
const HomePage({super.key});
|
const HomePage({super.key});
|
||||||
|
|
||||||
|
@ -15,7 +13,6 @@ class HomePage extends StatefulWidget {
|
||||||
|
|
||||||
class _HomePageState extends State<HomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
late AMapController _mapController;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -37,14 +34,14 @@ class _HomePageState extends State<HomePage> {
|
||||||
)),
|
)),
|
||||||
backgroundColor: const Color(0xFFF3F3F3),
|
backgroundColor: const Color(0xFFF3F3F3),
|
||||||
body: PopScope(
|
body: PopScope(
|
||||||
canPop: false,
|
canPop: true, //能否向右滑动返回上一页
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
buildTopWidget(),
|
buildTopWidget(),
|
||||||
buildMiddleWidget(),
|
buildMiddleWidget(),
|
||||||
buildBottomWidget()
|
const MapWidget()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -227,59 +224,4 @@ class _HomePageState extends State<HomePage> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBottomWidget() {
|
|
||||||
AMapWidget map = AMapWidget(
|
|
||||||
///必须正确设置的合规隐私声明,否则SDK不会工作,会造成地图白屏等问题。
|
|
||||||
privacyStatement: ConstConfig.amapPrivacyStatement,
|
|
||||||
apiKey: ConstConfig.amapApiKeys,
|
|
||||||
mapType: MapType.navi,
|
|
||||||
scaleEnabled: false,
|
|
||||||
myLocationStyleOptions: MyLocationStyleOptions(
|
|
||||||
true,
|
|
||||||
circleFillColor: Colors.lightBlue,
|
|
||||||
circleStrokeColor: Colors.blue,
|
|
||||||
circleStrokeWidth: 1,
|
|
||||||
),
|
|
||||||
onMapCreated: (AMapController controller) {
|
|
||||||
setState(() {
|
|
||||||
_mapController = controller;
|
|
||||||
getApprovalNumber();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return Expanded(
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(top: 10, bottom: 10),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(5))),
|
|
||||||
child: map,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 20,
|
|
||||||
right: 20,
|
|
||||||
child: Image.asset(
|
|
||||||
"images/3.0x/current_location.png",
|
|
||||||
width: 30,
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
///获取审图号
|
|
||||||
void getApprovalNumber() async {
|
|
||||||
//普通地图审图号
|
|
||||||
String? mapContentApprovalNumber =
|
|
||||||
await _mapController.getMapContentApprovalNumber();
|
|
||||||
//卫星地图审图号
|
|
||||||
String? satelliteImageApprovalNumber =
|
|
||||||
await _mapController.getSatelliteImageApprovalNumber();
|
|
||||||
print('地图审图号(普通地图): $mapContentApprovalNumber');
|
|
||||||
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:amap_flutter_location/amap_flutter_location.dart';
|
||||||
|
import 'package:amap_flutter_location/amap_location_option.dart';
|
||||||
|
import 'package:amap_flutter_map/amap_flutter_map.dart';
|
||||||
|
import 'package:autosos_flutter/const_config.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:amap_flutter_base/amap_flutter_base.dart';
|
||||||
|
|
||||||
|
class MapWidget extends StatefulWidget {
|
||||||
|
const MapWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MapWidget> createState() => _MapWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MapWidgetState extends State<MapWidget> {
|
||||||
|
late AMapController _mapController;
|
||||||
|
Map<String, Object> _locationResult = {};
|
||||||
|
late StreamSubscription<Map<String, Object>> _locationListener;
|
||||||
|
final AMapFlutterLocation _locationPlugin = AMapFlutterLocation();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_locationListener.cancel();
|
||||||
|
_locationPlugin.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
/// 设置是否已经包含高德隐私政策并弹窗展示显示用户查看,如果未包含或者没有弹窗展示,高德定位SDK将不会工作
|
||||||
|
///
|
||||||
|
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
||||||
|
/// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
|
||||||
|
///
|
||||||
|
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
||||||
|
///
|
||||||
|
/// [hasContains] 隐私声明中是否包含高德隐私政策说明
|
||||||
|
///
|
||||||
|
/// [hasShow] 隐私权政策是否弹窗展示告知用户
|
||||||
|
AMapFlutterLocation.updatePrivacyShow(true, true);
|
||||||
|
|
||||||
|
/// 设置是否已经取得用户同意,如果未取得用户同意,高德定位SDK将不会工作
|
||||||
|
///
|
||||||
|
/// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
|
||||||
|
///
|
||||||
|
/// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
|
||||||
|
///
|
||||||
|
/// [hasAgree] 隐私权政策是否已经取得用户同意
|
||||||
|
AMapFlutterLocation.updatePrivacyAgree(true);
|
||||||
|
|
||||||
|
/// 动态申请定位权限
|
||||||
|
requestPermission();
|
||||||
|
|
||||||
|
///设置Android和iOS的apiKey<br>
|
||||||
|
///
|
||||||
|
/// 定位Flutter插件提供了单独的设置ApiKey的接口,
|
||||||
|
/// 使用接口的优先级高于通过Native配置ApiKey的优先级(通过Api接口配置后,通过Native配置文件设置的key将不生效),
|
||||||
|
/// 使用时可根据实际情况决定使用哪种方式
|
||||||
|
///
|
||||||
|
///key的申请请参考高德开放平台官网说明<br>
|
||||||
|
///
|
||||||
|
///Android: https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key
|
||||||
|
///
|
||||||
|
///iOS: https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key
|
||||||
|
AMapFlutterLocation.setApiKey(ConstConfig.androidKey, ConstConfig.iosKey);
|
||||||
|
|
||||||
|
///iOS 获取native精度类型
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
requestAccuracyAuthorization();
|
||||||
|
}
|
||||||
|
|
||||||
|
_locationPlugin.setLocationOption(AMapLocationOption());
|
||||||
|
|
||||||
|
///注册定位结果监听
|
||||||
|
_locationListener = _locationPlugin
|
||||||
|
.onLocationChanged()
|
||||||
|
.listen((Map<String, Object> result) {
|
||||||
|
setState(() {
|
||||||
|
_locationResult = result;
|
||||||
|
});
|
||||||
|
print("location=$_locationResult");
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
|
_moveCamera(_locationResult);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
_locationPlugin.startLocation();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
AMapWidget map = AMapWidget(
|
||||||
|
///必须正确设置的合规隐私声明,否则SDK不会工作,会造成地图白屏等问题。
|
||||||
|
privacyStatement: ConstConfig.amapPrivacyStatement,
|
||||||
|
apiKey: ConstConfig.amapApiKeys,
|
||||||
|
mapType: MapType.navi,
|
||||||
|
scaleEnabled: false,
|
||||||
|
myLocationStyleOptions: MyLocationStyleOptions(
|
||||||
|
true,
|
||||||
|
circleFillColor: Colors.lightBlue,
|
||||||
|
circleStrokeColor: Colors.blue,
|
||||||
|
circleStrokeWidth: 1,
|
||||||
|
),
|
||||||
|
onMapCreated: (AMapController controller) {
|
||||||
|
setState(() {
|
||||||
|
_mapController = controller;
|
||||||
|
getApprovalNumber();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return Expanded(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 10, bottom: 10),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(5))),
|
||||||
|
child: map,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 20,
|
||||||
|
right: 20,
|
||||||
|
child: Image.asset(
|
||||||
|
"images/3.0x/current_location.png",
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _moveCamera(Map<String,Object> result) {
|
||||||
|
double lat = double.parse(result['latitude'] as String);
|
||||||
|
double lng = double.parse(result['longitude'] as String);
|
||||||
|
_mapController.moveCamera(
|
||||||
|
CameraUpdate.newCameraPosition(CameraPosition(target: LatLng(lat,lng))));
|
||||||
|
}
|
||||||
|
|
||||||
|
///获取审图号
|
||||||
|
void getApprovalNumber() async {
|
||||||
|
//普通地图审图号
|
||||||
|
String? mapContentApprovalNumber =
|
||||||
|
await _mapController.getMapContentApprovalNumber();
|
||||||
|
//卫星地图审图号
|
||||||
|
String? satelliteImageApprovalNumber =
|
||||||
|
await _mapController.getSatelliteImageApprovalNumber();
|
||||||
|
print('地图审图号(普通地图): $mapContentApprovalNumber');
|
||||||
|
print('地图审图号(卫星地图): $satelliteImageApprovalNumber');
|
||||||
|
}
|
||||||
|
|
||||||
|
void requestPermission() async {
|
||||||
|
// 申请权限
|
||||||
|
bool hasLocationPermission = await requestLocationPermission();
|
||||||
|
if (hasLocationPermission) {
|
||||||
|
print("定位权限申请通过");
|
||||||
|
} else {
|
||||||
|
print("定位权限申请不通过");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 申请定位权限
|
||||||
|
/// 授予定位权限返回true, 否则返回false
|
||||||
|
Future<bool> requestLocationPermission() async {
|
||||||
|
//获取当前的权限
|
||||||
|
var status = await Permission.locationAlways.status;
|
||||||
|
if (status == PermissionStatus.granted) {
|
||||||
|
//已经授权
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
//未授权则发起一次申请
|
||||||
|
status = await Permission.locationAlways.request();
|
||||||
|
if (status == PermissionStatus.granted) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///获取iOS native的accuracyAuthorization类型
|
||||||
|
void requestAccuracyAuthorization() async {
|
||||||
|
AMapAccuracyAuthorization currentAccuracyAuthorization =
|
||||||
|
await _locationPlugin.getSystemAccuracyAuthorization();
|
||||||
|
if (currentAccuracyAuthorization ==
|
||||||
|
AMapAccuracyAuthorization.AMapAccuracyAuthorizationFullAccuracy) {
|
||||||
|
print("精确定位类型");
|
||||||
|
} else if (currentAccuracyAuthorization ==
|
||||||
|
AMapAccuracyAuthorization.AMapAccuracyAuthorizationReducedAccuracy) {
|
||||||
|
print("模糊定位类型");
|
||||||
|
} else {
|
||||||
|
print("未知定位类型");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
SPUtil spUtil = SPUtil();
|
SPUtil spUtil = SPUtil();
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
_unameController.text = "14725803690";
|
||||||
|
_pwdController.text = "123456";
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
@ -70,6 +72,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
|
obscureText: true,
|
||||||
controller: _pwdController,
|
controller: _pwdController,
|
||||||
decoration: const InputDecoration(hintText: "请输入密码"),
|
decoration: const InputDecoration(hintText: "请输入密码"),
|
||||||
))
|
))
|
||||||
|
|
48
pubspec.lock
48
pubspec.lock
|
@ -312,6 +312,54 @@ packages:
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.1"
|
version: "2.2.1"
|
||||||
|
permission_handler:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: permission_handler
|
||||||
|
sha256: "74e962b7fad7ff75959161bb2c0ad8fe7f2568ee82621c9c2660b751146bfe44"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "11.3.0"
|
||||||
|
permission_handler_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_android
|
||||||
|
sha256: "1acac6bae58144b442f11e66621c062aead9c99841093c38f5bcdcc24c1c3474"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "12.0.5"
|
||||||
|
permission_handler_apple:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_apple
|
||||||
|
sha256: bdafc6db74253abb63907f4e357302e6bb786ab41465e8635f362ee71fd8707b
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "9.4.0"
|
||||||
|
permission_handler_html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_html
|
||||||
|
sha256: "54bf176b90f6eddd4ece307e2c06cf977fb3973719c35a93b85cc7093eb6070d"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.1"
|
||||||
|
permission_handler_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_platform_interface
|
||||||
|
sha256: "23dfba8447c076ab5be3dee9ceb66aad345c4a648f0cac292c77b1eb0e800b78"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "4.2.0"
|
||||||
|
permission_handler_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: permission_handler_windows
|
||||||
|
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -40,6 +40,7 @@ dependencies:
|
||||||
uuid: ^4.3.3
|
uuid: ^4.3.3
|
||||||
device_info_plus: ^9.1.2
|
device_info_plus: ^9.1.2
|
||||||
getuiflut: ^0.2.25
|
getuiflut: ^0.2.25
|
||||||
|
permission_handler: ^11.3.0
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|
Loading…
Reference in New Issue