李志伟 3 years ago
parent
commit
53890268b6

+ 29
- 3
android/app/build.gradle View File

26
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27
 
27
 
28
 android {
28
 android {
29
-    compileSdkVersion flutter.compileSdkVersion
29
+    compileSdkVersion 31
30
 
30
 
31
     compileOptions {
31
     compileOptions {
32
         sourceCompatibility JavaVersion.VERSION_1_8
32
         sourceCompatibility JavaVersion.VERSION_1_8
36
     defaultConfig {
36
     defaultConfig {
37
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
37
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
38
         applicationId "com.example.worker_client"
38
         applicationId "com.example.worker_client"
39
-        minSdkVersion flutter.minSdkVersion
40
-        targetSdkVersion flutter.targetSdkVersion
39
+        minSdkVersion 21
40
+        targetSdkVersion 28
41
         versionCode flutterVersionCode.toInteger()
41
         versionCode flutterVersionCode.toInteger()
42
         versionName flutterVersionName
42
         versionName flutterVersionName
43
     }
43
     }
44
+    signingConfigs {
45
+        debug {
46
+            //keystore中key的别名
47
+            keyAlias 'mykey'
48
+            //keystore中key的密码
49
+            keyPassword 'SJPrpy7yF8XdkXHY'
50
+            //keystore的文件路径,可以是绝对路径也可以是相对路径
51
+            storeFile file('../machinery.keystore')
52
+            //keystore的密码l
53
+            storePassword 'Op4CCmT20L0c0fLP'
54
+        }
55
+    }
56
+
57
+    dependencies {
58
+        implementation('com.amap.api:3dmap:9.1.0')
59
+        implementation('com.amap.api:location:6.1.0')
60
+    }
44
 
61
 
45
     buildTypes {
62
     buildTypes {
63
+        debug {
64
+            minifyEnabled false
65
+        }
46
         release {
66
         release {
47
             // TODO: Add your own signing config for the release build.
67
             // TODO: Add your own signing config for the release build.
48
             // Signing with the debug keys for now, so `flutter run --release` works.
68
             // Signing with the debug keys for now, so `flutter run --release` works.
49
             signingConfig signingConfigs.debug
69
             signingConfig signingConfigs.debug
70
+
71
+            //关闭混淆, 否则在运行release包后可能出现运行崩溃, TODO后续进行混淆配置
72
+            minifyEnabled false //删除无用代码
73
+            shrinkResources false //删除无用资源
50
         }
74
         }
51
     }
75
     }
52
 }
76
 }
54
 flutter {
78
 flutter {
55
     source '../..'
79
     source '../..'
56
 }
80
 }
81
+
82
+

+ 30
- 0
android/app/src/main/AndroidManifest.xml View File

1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+    xmlns:tools="http://schemas.android.com/tools"
2
     package="com.example.worker_client">
3
     package="com.example.worker_client">
4
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
5
+    <!--允许获取精确位置,精准定位必选-->
6
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
7
+    <!--允许获取粗略位置,粗略定位必选-->
8
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
9
+    <!--允许获取设备和运营商信息,用于问题排查和网络定位(无gps情况下的定位),若需网络定位功能则必选-->
10
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
11
+    <!--允许获取网络状态,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
12
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
13
+    <!--允许获取wifi网络信息,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
14
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
15
+    <!--允许获取wifi状态改变,用于网络定位(无gps情况下的定位),若需网络定位功能则必选-->
16
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
17
+    <!--后台获取位置信息,若需后台定位则必选-->
18
+    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
19
+    <!--用于申请调用A-GPS模块,卫星定位加速-->
20
+    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
21
+    <!--允许写设备缓存,用于问题排查-->
22
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" tools:ignore="ProtectedPermissions" />
23
+    <!--允许写入扩展存储,用于写入缓存定位数据-->
24
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
25
+    <!--允许读设备等信息,用于问题排查-->
26
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
27
+
3
    <application
28
    <application
4
         android:label="worker_client"
29
         android:label="worker_client"
5
         android:name="${applicationName}"
30
         android:name="${applicationName}"
30
         <meta-data
55
         <meta-data
31
             android:name="flutterEmbedding"
56
             android:name="flutterEmbedding"
32
             android:value="2" />
57
             android:value="2" />
58
+       <meta-data
59
+           android:name="com.amap.api.v2.apikey"
60
+           android:value="b481b4187e24e625fa0056fd0530e663"/>
61
+       <service android:name="com.amap.api.location.APSService"
62
+           tools:ignore="MissingClass" />
33
     </application>
63
     </application>
34
 </manifest>
64
 </manifest>

+ 0
- 6
android/app/src/main/java/com/example/worker_client/MainActivity.java View File

1
-package com.example.worker_client;
2
-
3
-import io.flutter.embedding.android.FlutterActivity;
4
-
5
-public class MainActivity extends FlutterActivity {
6
-}

+ 6
- 0
android/app/src/main/kotlin/com/example/worker_client/MainActivity.kt View File

1
+package com.example.worker_client
2
+
3
+import io.flutter.embedding.android.FlutterActivity
4
+
5
+class MainActivity: FlutterActivity() {
6
+}

BIN
android/app/src/main/res/drawable/launch_image.png View File


+ 1
- 1
android/app/src/main/res/values/styles.xml View File

4
     <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
4
     <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
5
         <!-- Show a splash screen on the activity. Automatically removed when
5
         <!-- Show a splash screen on the activity. Automatically removed when
6
              Flutter draws its first frame -->
6
              Flutter draws its first frame -->
7
-        <item name="android:windowBackground">@drawable/launch_background</item>
7
+        <item name="android:windowBackground">@drawable/launch_image</item>
8
     </style>
8
     </style>
9
     <!-- Theme applied to the Android Window as soon as the process has started.
9
     <!-- Theme applied to the Android Window as soon as the process has started.
10
          This theme determines the color of the Android Window while your
10
          This theme determines the color of the Android Window while your

+ 36
- 35
lib/models/app.dart View File

1
 
1
 
2
 import 'dart:io';
2
 import 'dart:io';
3
 
3
 
4
-// import 'package:amap_flutter_location/amap_flutter_location.dart';
4
+import 'package:amap_flutter_location/amap_flutter_location.dart';
5
 import '/models/entities/person.dart';
5
 import '/models/entities/person.dart';
6
-// import '/widgets/Modal.dart';
6
+import '/widgets/Modal.dart';
7
 import 'package:get/get.dart';
7
 import 'package:get/get.dart';
8
-// import '../utils/location.dart';
8
+import '../utils/location.dart';
9
 
9
 
10
 class AppController extends GetxController {
10
 class AppController extends GetxController {
11
   // 有了这句, 可以直接 AppController.t 调用
11
   // 有了这句, 可以直接 AppController.t 调用
15
   final location = Rxn<Map<String, Object>>();
15
   final location = Rxn<Map<String, Object>>();
16
   final testInt = 1.obs;
16
   final testInt = 1.obs;
17
 
17
 
18
-  // AMapFlutterLocation? _location;
19
-  //
20
-  // get locationStr {
21
-  //   if (null == location.value) return null;
22
-  //
23
-  //   double longitude = location.value!['longitude'] as double;
24
-  //   double latitude = location.value!['latitude'] as double;
25
-  //
26
-  //   return longitude.toString() + "," + latitude.toString();
27
-  // }
28
-  //
29
-  // void onLocationChange (Map<String, Object> result) {
30
-  //   location(result);
31
-  // }
18
+  AMapFlutterLocation? _location;
19
+
20
+  get locationStr {
21
+    if (null == location.value) return null;
22
+
23
+    double longitude = location.value!['longitude'] as double;
24
+    double latitude = location.value!['latitude'] as double;
25
+
26
+    return longitude.toString() + "," + latitude.toString();
27
+  }
28
+
29
+  void onLocationChange (Map<String, Object> result) {
30
+
31
+    location(result);
32
+  }
32
 
33
 
33
   @override
34
   @override
34
   void onInit() {
35
   void onInit() {
35
     super.onInit();
36
     super.onInit();
36
 
37
 
37
-    // 尝试获取 location
38
-    // requireLocation(onLocationChange).then((loc) {
39
-    //   _location = loc;
40
-    // }).catchError((e) {
41
-    //   print(e);
42
-    //
43
-    //   showAlert(
44
-    //     title: '获取定位失败',
45
-    //     message: e.message,
46
-    //     onConfirm: () => exit(1),
47
-    //   );
48
-    // });
38
+    //尝试获取 location
39
+    requireLocation(onLocationChange).then((loc) {
40
+      _location = loc;
41
+    }).catchError((e) {
42
+      print(e);
43
+
44
+      showAlert(
45
+        title: '获取定位失败',
46
+        message: e.message,
47
+        onConfirm: () => exit(1),
48
+      );
49
+    });
49
 
50
 
50
     // // 尝试获取一次人员信息
51
     // // 尝试获取一次人员信息
51
     // getCurrent().then((person) {
52
     // getCurrent().then((person) {
55
     // });
56
     // });
56
   }
57
   }
57
 
58
 
58
-  // @override
59
-  // void onClose() {
60
-  //   if (null != _location) {
61
-  //     _location?.destroy();
62
-  //   }
63
-  // }
59
+  @override
60
+  void onClose() {
61
+    if (null != _location) {
62
+      _location?.destroy();
63
+    }
64
+  }
64
 
65
 
65
 }
66
 }

+ 1
- 2
lib/pages/Login/index.dart View File

8
 import 'package:get/get.dart';
8
 import 'package:get/get.dart';
9
 import 'package:worker_client/widgets/Cell.dart';
9
 import 'package:worker_client/widgets/Cell.dart';
10
 import 'package:worker_client/widgets/GradientButton.dart';
10
 import 'package:worker_client/widgets/GradientButton.dart';
11
-import 'package:worker_client/pages/home/index.dart';
12
 import 'package:worker_client/widgets/MyButton/index.dart';
11
 import 'package:worker_client/widgets/MyButton/index.dart';
13
 import '../../models/entities/person.dart';
12
 import '../../models/entities/person.dart';
14
 import '../../services/user.dart';
13
 import '../../services/user.dart';
85
           userLogin(phone, qCode).then((res) {
84
           userLogin(phone, qCode).then((res) {
86
             userInfo(Person.fromJson(res['person']));
85
             userInfo(Person.fromJson(res['person']));
87
             Fluttertoast.showToast(msg: '登录成功!');
86
             Fluttertoast.showToast(msg: '登录成功!');
88
-            Get.off(Home());
87
+            Get.offNamed('/home');
89
           }).catchError((err) {
88
           }).catchError((err) {
90
             Fluttertoast.showToast(msg: err);
89
             Fluttertoast.showToast(msg: err);
91
           });
90
           });

+ 30
- 31
lib/pages/home/index.dart View File

115
                         required bool haveMore}) {
115
                         required bool haveMore}) {
116
                       return RefreshBuilder(
116
                       return RefreshBuilder(
117
                         fetch: (params) => getJobList(params),
117
                         fetch: (params) => getJobList(params),
118
-                        useState: (value) {jobList(GetList(value.records));},
118
+                        useState: (value) {
119
+                          jobList(GetList(value.records));
120
+                        },
119
                         builder: (
121
                         builder: (
120
                             {required BuildContext context,
122
                             {required BuildContext context,
121
                             required Function toggle}) {
123
                             required Function toggle}) {
122
                           Refresh = toggle;
124
                           Refresh = toggle;
123
-                          return
124
-
125
-                                ListView.builder(
125
+                          return ListView.builder(
126
                               controller: scrollController,
126
                               controller: scrollController,
127
                               itemCount: 1,
127
                               itemCount: 1,
128
                               itemBuilder:
128
                               itemBuilder:
131
                                   ...jobList.value,
131
                                   ...jobList.value,
132
                                   ...GetList(data.records)
132
                                   ...GetList(data.records)
133
                                 ]);
133
                                 ]);
134
-                                return Obx((){if (jobList.value != []) {
135
-                                  return Column(
136
-                                    children: jobList.value
137
-                                        .map(
138
-                                          (item) => MyCard(
139
-                                            item: item,
140
-                                            job: true,
141
-                                            detail: false,
142
-                                            onClick: () {
143
-                                              changeJob(item);
144
-                                            },
145
-                                            goDetail: () {
146
-                                              goDetail(item);
147
-                                            },
148
-                                            buttomText: item.status == 0
149
-                                                ? '开始作业'
150
-                                                : '完成作业',
151
-                                          ),
152
-                                        )
153
-                                        .toList(),
154
-                                  );
155
-                                } else {
156
-                                  return const Text('暂无数据');
157
-                                }
158
-                                }
134
+                                return Obx(() {
135
+                                  if (jobList.value != []) {
136
+                                    return Column(
137
+                                      children: jobList.value
138
+                                          .map(
139
+                                            (item) => MyCard(
140
+                                              item: item,
141
+                                              job: true,
142
+                                              detail: false,
143
+                                              onClick: () {
144
+                                                changeJob(item);
145
+                                              },
146
+                                              goDetail: () {
147
+                                                goDetail(item);
148
+                                              },
149
+                                              buttomText: item.status == 0
150
+                                                  ? '开始作业'
151
+                                                  : '完成作业',
152
+                                            ),
153
+                                          )
154
+                                          .toList(),
159
                                     );
155
                                     );
160
-                              })
161
-                          ;
156
+                                  } else {
157
+                                    return const Text('暂无数据');
158
+                                  }
159
+                                });
160
+                              });
162
                         },
161
                         },
163
                         onError: () {},
162
                         onError: () {},
164
                       );
163
                       );

+ 1
- 0
lib/pages/jobDetail/index.dart View File

8
 import '/widgets/MyDialog.dart' as modal;
8
 import '/widgets/MyDialog.dart' as modal;
9
 
9
 
10
 class JobDetail extends BasicPage {
10
 class JobDetail extends BasicPage {
11
+
11
   final job = Rx<Job>(Job());
12
   final job = Rx<Job>(Job());
12
   @override
13
   @override
13
   void beforeShow() {
14
   void beforeShow() {

+ 22
- 0
lib/utils/amap/const_config.dart View File

1
+import 'package:amap_flutter_base/amap_flutter_base.dart';
2
+import 'package:amap_flutter_map/amap_flutter_map.dart';
3
+
4
+class ConstConfig {
5
+  ///配置您申请的apikey,在此处配置之后,可以在初始化[AMapWidget]时,通过`apiKey`属性设置
6
+  ///
7
+  ///注意:使用[AMapWidget]的`apiKey`属性设置的key的优先级高于通过Native配置key的优先级,
8
+  ///使用[AMapWidget]的`apiKey`属性配置后Native配置的key将失效,请根据实际情况选择使用
9
+  static const AMapApiKey amapApiKeys = AMapApiKey(
10
+      androidKey: 'b481b4187e24e625fa0056fd0530e663',
11
+      iosKey: '您申请的iOS平台的key');
12
+
13
+  ///高德隐私合规声明,这里只是示例,实际使用中请按照实际参数设置[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数
14
+  ///
15
+  /// 注意:[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数中有一个为false,高德SDK均不会工作,会造成地图白屏等现象
16
+  ///
17
+  /// 高德开发者合规指南请参考:https://lbs.amap.com/agreement/compliance
18
+  ///
19
+  /// 高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy
20
+  static const AMapPrivacyStatement amapPrivacyStatement =
21
+  AMapPrivacyStatement(hasContains: true, hasShow: true, hasAgree: true);
22
+}

+ 134
- 0
lib/utils/location.dart View File

1
+import 'dart:async';
2
+
3
+import 'package:amap_flutter_location/amap_flutter_location.dart';
4
+import 'package:amap_flutter_location/amap_location_option.dart';
5
+import 'package:permission_handler/permission_handler.dart';
6
+
7
+import 'amap/const_config.dart';
8
+
9
+typedef AMAPListener = void Function (Map<String, Object>);
10
+
11
+void showPrivacy() {
12
+  /// 设置是否已经包含高德隐私政策并弹窗展示显示用户查看,如果未包含或者没有弹窗展示,高德定位SDK将不会工作
13
+  ///
14
+  /// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
15
+  /// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
16
+  ///
17
+  /// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
18
+  ///
19
+  /// [hasContains] 隐私声明中是否包含高德隐私政策说明
20
+  ///
21
+  /// [hasShow] 隐私权政策是否弹窗展示告知用户
22
+  AMapFlutterLocation.updatePrivacyShow(true, true);
23
+
24
+  /// 设置是否已经取得用户同意,如果未取得用户同意,高德定位SDK将不会工作
25
+  ///
26
+  /// 高德SDK合规使用方案请参考官网地址:https://lbs.amap.com/news/sdkhgsy
27
+  ///
28
+  /// <b>必须保证在调用定位功能之前调用, 建议首次启动App时弹出《隐私政策》并取得用户同意</b>
29
+  ///
30
+  /// [hasAgree] 隐私权政策是否已经取得用户同意
31
+  AMapFlutterLocation.updatePrivacyAgree(true);
32
+}
33
+
34
+// 判断定位权限
35
+Future _requirePermission() async {
36
+  PermissionStatus _permissionGranted = await Permission.location.status;
37
+  if (_permissionGranted == PermissionStatus.denied) {
38
+    // 如果未允许, 尝试申请一次
39
+    _permissionGranted = await Permission.location.request();
40
+    if (_permissionGranted != PermissionStatus.granted) {
41
+      throw Exception("请设置允许当前程序定位功能");
42
+    }
43
+  }
44
+}
45
+
46
+Future requireLocation(AMAPListener listener) async {
47
+  AMapFlutterLocation.setApiKey(ConstConfig.amapApiKeys.androidKey!, ConstConfig.amapApiKeys.iosKey!);
48
+  showPrivacy();
49
+  await _requirePermission();
50
+  final AMapFlutterLocation location = AMapFlutterLocation();
51
+  location.onLocationChanged().listen(listener);
52
+  location.setLocationOption(_getAMapLocationOption());
53
+  location.startLocation();
54
+
55
+  return location;
56
+}
57
+
58
+_getAMapLocationOption() {
59
+  AMapLocationOption locationOption = new AMapLocationOption();
60
+
61
+  ///是否单次定位
62
+  locationOption.onceLocation = false;
63
+
64
+  ///是否需要返回逆地理信息
65
+  locationOption.needAddress = true;
66
+
67
+  ///逆地理信息的语言类型
68
+  locationOption.geoLanguage = GeoLanguage.DEFAULT;
69
+
70
+  locationOption.desiredLocationAccuracyAuthorizationMode =
71
+      AMapLocationAccuracyAuthorizationMode.ReduceAccuracy;
72
+
73
+  locationOption.fullAccuracyPurposeKey = "AMapLocationScene";
74
+
75
+  ///设置Android端连续定位的定位间隔
76
+  locationOption.locationInterval = 2000;
77
+
78
+  ///设置Android端的定位模式<br>
79
+  ///可选值:<br>
80
+  ///<li>[AMapLocationMode.Battery_Saving]</li>
81
+  ///<li>[AMapLocationMode.Device_Sensors]</li>
82
+  ///<li>[AMapLocationMode.Hight_Accuracy]</li>
83
+  locationOption.locationMode = AMapLocationMode.Hight_Accuracy;
84
+
85
+  ///设置iOS端的定位最小更新距离<br>
86
+  locationOption.distanceFilter = -1;
87
+
88
+  ///设置iOS端期望的定位精度
89
+  /// 可选值:<br>
90
+  /// <li>[DesiredAccuracy.Best] 最高精度</li>
91
+  /// <li>[DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度 </li>
92
+  /// <li>[DesiredAccuracy.NearestTenMeters] 10米 </li>
93
+  /// <li>[DesiredAccuracy.Kilometer] 1000米</li>
94
+  /// <li>[DesiredAccuracy.ThreeKilometers] 3000米</li>
95
+  locationOption.desiredAccuracy = DesiredAccuracy.Best;
96
+
97
+  ///设置iOS端是否允许系统暂停定位
98
+  locationOption.pausesLocationUpdatesAutomatically = false;
99
+
100
+  return locationOption;
101
+}
102
+
103
+
104
+// import 'dart:io';
105
+//
106
+// import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'
107
+//     show BMFMapSDK, BMF_COORD_TYPE;
108
+// import 'package:flutter_bmflocation/flutter_bmflocation.dart';
109
+// import 'package:permission_handler/permission_handler.dart';
110
+//
111
+// Future requireLocation() async {
112
+//   // 判断定位权限
113
+//   PermissionStatus _permissionGranted = await Permission.location.status;
114
+//   if (_permissionGranted == PermissionStatus.denied) {
115
+//     // 如果未允许, 尝试申请一次
116
+//     _permissionGranted = await Permission.location.request();
117
+//     if (_permissionGranted != PermissionStatus.granted) {
118
+//       throw Exception("请设置允许当前程序定位功能");
119
+//     }
120
+//   }
121
+//
122
+//   final LocationFlutterPlugin location = LocationFlutterPlugin();
123
+//
124
+//   // 设置是否隐私政策
125
+//   location.setAgreePrivacy(true);
126
+//   BMFMapSDK.setAgreePrivacy(true);
127
+//   if (Platform.isAndroid) {
128
+//     // Android 目前不支持接口设置Apikey,
129
+//     // 请在主工程的Manifest文件里设置,详细配置方法请参考官网(https://lbsyun.baidu.com/)demo
130
+//     BMFMapSDK.setCoordType(BMF_COORD_TYPE.COMMON);
131
+//   }
132
+//
133
+//   return location;
134
+// }

+ 4
- 8
lib/widgets/MyCard/index.dart View File

244
                 Visibility(
244
                 Visibility(
245
                     child: CardCell(
245
                     child: CardCell(
246
                         lable: '作业时间',
246
                         lable: '作业时间',
247
-                        content: item is Job ? item.startDate.toString() : '',
247
+                        content: item.startDate.toString() +
248
+                            (item.endDate != null
249
+                                ? '\n' + item.endDate.toString()
250
+                                : ''),
248
                         size: 2),
251
                         size: 2),
249
                     visible: job),
252
                     visible: job),
250
-                Visibility(
251
-                    child: CardCell(
252
-                        lable: '',
253
-                        content:
254
-                            (item is Job ? item.endDate ?? '' : '').toString(),
255
-                        size: 2),
256
-                    visible: job&&item.endDate!=null),
257
                 CardCell(
253
                 CardCell(
258
                     lable: '订单费用',
254
                     lable: '订单费用',
259
                     content: ((item.charges ?? 0) / 100).toString(),
255
                     content: ((item.charges ?? 0) / 100).toString(),

+ 42
- 0
lib/widgets/amap/amap.dart View File

1
+import 'package:amap_flutter_map/amap_flutter_map.dart';
2
+import 'package:amap_flutter_base/amap_flutter_base.dart';
3
+import 'package:flutter/widgets.dart';
4
+
5
+import '/utils/amap/const_config.dart';
6
+
7
+// https://developer.amap.com/api/flutter/guide/map-flutter-plug-in/map-flutter-info
8
+class AMap extends StatelessWidget {
9
+  late AMapController _mapController;
10
+  final LatLng? position;
11
+  final Map<String, Marker> _markers = Map<String, Marker>();
12
+
13
+  AMap({Key? key,  this.position }): super(key: key);
14
+
15
+  void onMapCreated(AMapController controller) {
16
+    _mapController = controller;
17
+  }
18
+
19
+  void _initMarkers() {
20
+    if (null != position) {
21
+      Marker marker = Marker(
22
+        position: position!,
23
+        icon: BitmapDescriptor.fromIconPath("images/locationImage.png")
24
+      );
25
+      _markers[marker.id] = marker;
26
+    }
27
+  }
28
+
29
+  @override
30
+  Widget build(BuildContext context) {
31
+    _initMarkers();
32
+
33
+    return AMapWidget(
34
+      privacyStatement: ConstConfig.amapPrivacyStatement,
35
+      apiKey: ConstConfig.amapApiKeys,
36
+      markers: Set<Marker>.of(_markers.values),
37
+      // 默认是邓州市中心
38
+      initialCameraPosition: const CameraPosition(target: LatLng(32.687732, 112.08745)),
39
+    );
40
+  }
41
+
42
+}

+ 22
- 0
lib/widgets/amap/const_config.dart View File

1
+import 'package:amap_flutter_base/amap_flutter_base.dart';
2
+import 'package:amap_flutter_map/amap_flutter_map.dart';
3
+
4
+class ConstConfig {
5
+  ///配置您申请的apikey,在此处配置之后,可以在初始化[AMapWidget]时,通过`apiKey`属性设置
6
+  ///
7
+  ///注意:使用[AMapWidget]的`apiKey`属性设置的key的优先级高于通过Native配置key的优先级,
8
+  ///使用[AMapWidget]的`apiKey`属性配置后Native配置的key将失效,请根据实际情况选择使用
9
+  static const AMapApiKey amapApiKeys = AMapApiKey(
10
+      androidKey: 'b481b4187e24e625fa0056fd0530e663',
11
+      iosKey: '您申请的iOS平台的key');
12
+
13
+  ///高德隐私合规声明,这里只是示例,实际使用中请按照实际参数设置[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数
14
+  ///
15
+  /// 注意:[AMapPrivacyStatement]的'hasContains''hasShow''hasAgree'这三个参数中有一个为false,高德SDK均不会工作,会造成地图白屏等现象
16
+  ///
17
+  /// 高德开发者合规指南请参考:https://lbs.amap.com/agreement/compliance
18
+  ///
19
+  /// 高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy
20
+  static const AMapPrivacyStatement amapPrivacyStatement =
21
+  AMapPrivacyStatement(hasContains: true, hasShow: true, hasAgree: true);
22
+}

+ 210
- 0
pubspec.lock View File

1
 # Generated by pub
1
 # Generated by pub
2
 # See https://dart.dev/tools/pub/glossary#lockfile
2
 # See https://dart.dev/tools/pub/glossary#lockfile
3
 packages:
3
 packages:
4
+  _fe_analyzer_shared:
5
+    dependency: transitive
6
+    description:
7
+      name: _fe_analyzer_shared
8
+      url: "https://pub.flutter-io.cn"
9
+    source: hosted
10
+    version: "39.0.0"
11
+  amap_flutter_base:
12
+    dependency: transitive
13
+    description:
14
+      name: amap_flutter_base
15
+      url: "https://pub.flutter-io.cn"
16
+    source: hosted
17
+    version: "3.0.0"
18
+  amap_flutter_location:
19
+    dependency: "direct main"
20
+    description:
21
+      name: amap_flutter_location
22
+      url: "https://pub.flutter-io.cn"
23
+    source: hosted
24
+    version: "3.0.0"
25
+  amap_flutter_map:
26
+    dependency: "direct main"
27
+    description:
28
+      name: amap_flutter_map
29
+      url: "https://pub.flutter-io.cn"
30
+    source: hosted
31
+    version: "3.0.0"
32
+  analyzer:
33
+    dependency: transitive
34
+    description:
35
+      name: analyzer
36
+      url: "https://pub.flutter-io.cn"
37
+    source: hosted
38
+    version: "4.0.0"
39
+  args:
40
+    dependency: transitive
41
+    description:
42
+      name: args
43
+      url: "https://pub.flutter-io.cn"
44
+    source: hosted
45
+    version: "2.3.0"
4
   async:
46
   async:
5
     dependency: transitive
47
     dependency: transitive
6
     description:
48
     description:
15
       url: "https://pub.flutter-io.cn"
57
       url: "https://pub.flutter-io.cn"
16
     source: hosted
58
     source: hosted
17
     version: "2.1.0"
59
     version: "2.1.0"
60
+  build:
61
+    dependency: transitive
62
+    description:
63
+      name: build
64
+      url: "https://pub.flutter-io.cn"
65
+    source: hosted
66
+    version: "2.3.0"
67
+  build_config:
68
+    dependency: transitive
69
+    description:
70
+      name: build_config
71
+      url: "https://pub.flutter-io.cn"
72
+    source: hosted
73
+    version: "1.0.0"
18
   carousel_slider:
74
   carousel_slider:
19
     dependency: "direct main"
75
     dependency: "direct main"
20
     description:
76
     description:
36
       url: "https://pub.flutter-io.cn"
92
       url: "https://pub.flutter-io.cn"
37
     source: hosted
93
     source: hosted
38
     version: "1.3.1"
94
     version: "1.3.1"
95
+  checked_yaml:
96
+    dependency: transitive
97
+    description:
98
+      name: checked_yaml
99
+      url: "https://pub.flutter-io.cn"
100
+    source: hosted
101
+    version: "2.0.1"
39
   clock:
102
   clock:
40
     dependency: transitive
103
     dependency: transitive
41
     description:
104
     description:
50
       url: "https://pub.flutter-io.cn"
113
       url: "https://pub.flutter-io.cn"
51
     source: hosted
114
     source: hosted
52
     version: "1.15.0"
115
     version: "1.15.0"
116
+  convert:
117
+    dependency: transitive
118
+    description:
119
+      name: convert
120
+      url: "https://pub.flutter-io.cn"
121
+    source: hosted
122
+    version: "3.0.1"
123
+  crypto:
124
+    dependency: transitive
125
+    description:
126
+      name: crypto
127
+      url: "https://pub.flutter-io.cn"
128
+    source: hosted
129
+    version: "3.0.2"
53
   cupertino_icons:
130
   cupertino_icons:
54
     dependency: "direct main"
131
     dependency: "direct main"
55
     description:
132
     description:
57
       url: "https://pub.flutter-io.cn"
134
       url: "https://pub.flutter-io.cn"
58
     source: hosted
135
     source: hosted
59
     version: "1.0.4"
136
     version: "1.0.4"
137
+  dart_style:
138
+    dependency: transitive
139
+    description:
140
+      name: dart_style
141
+      url: "https://pub.flutter-io.cn"
142
+    source: hosted
143
+    version: "2.2.3"
60
   dio:
144
   dio:
61
     dependency: "direct main"
145
     dependency: "direct main"
62
     description:
146
     description:
97
       url: "https://pub.flutter-io.cn"
181
       url: "https://pub.flutter-io.cn"
98
     source: hosted
182
     source: hosted
99
     version: "1.0.4"
183
     version: "1.0.4"
184
+  flutter_plugin_android_lifecycle:
185
+    dependency: transitive
186
+    description:
187
+      name: flutter_plugin_android_lifecycle
188
+      url: "https://pub.flutter-io.cn"
189
+    source: hosted
190
+    version: "2.0.5"
100
   flutter_screenutil:
191
   flutter_screenutil:
101
     dependency: "direct main"
192
     dependency: "direct main"
102
     description:
193
     description:
135
       url: "https://pub.flutter-io.cn"
226
       url: "https://pub.flutter-io.cn"
136
     source: hosted
227
     source: hosted
137
     version: "2.0.3"
228
     version: "2.0.3"
229
+  glob:
230
+    dependency: transitive
231
+    description:
232
+      name: glob
233
+      url: "https://pub.flutter-io.cn"
234
+    source: hosted
235
+    version: "2.0.2"
138
   http_parser:
236
   http_parser:
139
     dependency: transitive
237
     dependency: transitive
140
     description:
238
     description:
149
       url: "https://pub.flutter-io.cn"
247
       url: "https://pub.flutter-io.cn"
150
     source: hosted
248
     source: hosted
151
     version: "0.6.3"
249
     version: "0.6.3"
250
+  json_annotation:
251
+    dependency: transitive
252
+    description:
253
+      name: json_annotation
254
+      url: "https://pub.flutter-io.cn"
255
+    source: hosted
256
+    version: "4.5.0"
257
+  json_serializable:
258
+    dependency: "direct main"
259
+    description:
260
+      name: json_serializable
261
+      url: "https://pub.flutter-io.cn"
262
+    source: hosted
263
+    version: "6.2.0"
152
   lints:
264
   lints:
153
     dependency: transitive
265
     dependency: transitive
154
     description:
266
     description:
156
       url: "https://pub.flutter-io.cn"
268
       url: "https://pub.flutter-io.cn"
157
     source: hosted
269
     source: hosted
158
     version: "1.0.1"
270
     version: "1.0.1"
271
+  logging:
272
+    dependency: transitive
273
+    description:
274
+      name: logging
275
+      url: "https://pub.flutter-io.cn"
276
+    source: hosted
277
+    version: "1.0.2"
159
   matcher:
278
   matcher:
160
     dependency: transitive
279
     dependency: transitive
161
     description:
280
     description:
177
       url: "https://pub.flutter-io.cn"
296
       url: "https://pub.flutter-io.cn"
178
     source: hosted
297
     source: hosted
179
     version: "1.7.0"
298
     version: "1.7.0"
299
+  package_config:
300
+    dependency: transitive
301
+    description:
302
+      name: package_config
303
+      url: "https://pub.flutter-io.cn"
304
+    source: hosted
305
+    version: "2.0.2"
180
   path:
306
   path:
181
     dependency: transitive
307
     dependency: transitive
182
     description:
308
     description:
233
       url: "https://pub.flutter-io.cn"
359
       url: "https://pub.flutter-io.cn"
234
     source: hosted
360
     source: hosted
235
     version: "2.0.5"
361
     version: "2.0.5"
362
+  permission_handler:
363
+    dependency: "direct main"
364
+    description:
365
+      name: permission_handler
366
+      url: "https://pub.flutter-io.cn"
367
+    source: hosted
368
+    version: "9.2.0"
369
+  permission_handler_android:
370
+    dependency: transitive
371
+    description:
372
+      name: permission_handler_android
373
+      url: "https://pub.flutter-io.cn"
374
+    source: hosted
375
+    version: "9.0.2+1"
376
+  permission_handler_apple:
377
+    dependency: transitive
378
+    description:
379
+      name: permission_handler_apple
380
+      url: "https://pub.flutter-io.cn"
381
+    source: hosted
382
+    version: "9.0.4"
383
+  permission_handler_platform_interface:
384
+    dependency: transitive
385
+    description:
386
+      name: permission_handler_platform_interface
387
+      url: "https://pub.flutter-io.cn"
388
+    source: hosted
389
+    version: "3.7.0"
390
+  permission_handler_windows:
391
+    dependency: transitive
392
+    description:
393
+      name: permission_handler_windows
394
+      url: "https://pub.flutter-io.cn"
395
+    source: hosted
396
+    version: "0.1.0"
236
   platform:
397
   platform:
237
     dependency: transitive
398
     dependency: transitive
238
     description:
399
     description:
254
       url: "https://pub.flutter-io.cn"
415
       url: "https://pub.flutter-io.cn"
255
     source: hosted
416
     source: hosted
256
     version: "4.2.4"
417
     version: "4.2.4"
418
+  pub_semver:
419
+    dependency: transitive
420
+    description:
421
+      name: pub_semver
422
+      url: "https://pub.flutter-io.cn"
423
+    source: hosted
424
+    version: "2.1.1"
425
+  pubspec_parse:
426
+    dependency: transitive
427
+    description:
428
+      name: pubspec_parse
429
+      url: "https://pub.flutter-io.cn"
430
+    source: hosted
431
+    version: "1.2.0"
257
   sky_engine:
432
   sky_engine:
258
     dependency: transitive
433
     dependency: transitive
259
     description: flutter
434
     description: flutter
260
     source: sdk
435
     source: sdk
261
     version: "0.0.99"
436
     version: "0.0.99"
437
+  source_gen:
438
+    dependency: transitive
439
+    description:
440
+      name: source_gen
441
+      url: "https://pub.flutter-io.cn"
442
+    source: hosted
443
+    version: "1.2.2"
444
+  source_helper:
445
+    dependency: transitive
446
+    description:
447
+      name: source_helper
448
+      url: "https://pub.flutter-io.cn"
449
+    source: hosted
450
+    version: "1.3.2"
262
   source_span:
451
   source_span:
263
     dependency: transitive
452
     dependency: transitive
264
     description:
453
     description:
280
       url: "https://pub.flutter-io.cn"
469
       url: "https://pub.flutter-io.cn"
281
     source: hosted
470
     source: hosted
282
     version: "2.1.0"
471
     version: "2.1.0"
472
+  stream_transform:
473
+    dependency: transitive
474
+    description:
475
+      name: stream_transform
476
+      url: "https://pub.flutter-io.cn"
477
+    source: hosted
478
+    version: "2.0.0"
283
   string_scanner:
479
   string_scanner:
284
     dependency: transitive
480
     dependency: transitive
285
     description:
481
     description:
315
       url: "https://pub.flutter-io.cn"
511
       url: "https://pub.flutter-io.cn"
316
     source: hosted
512
     source: hosted
317
     version: "2.1.1"
513
     version: "2.1.1"
514
+  watcher:
515
+    dependency: transitive
516
+    description:
517
+      name: watcher
518
+      url: "https://pub.flutter-io.cn"
519
+    source: hosted
520
+    version: "1.0.1"
318
   win32:
521
   win32:
319
     dependency: transitive
522
     dependency: transitive
320
     description:
523
     description:
329
       url: "https://pub.flutter-io.cn"
532
       url: "https://pub.flutter-io.cn"
330
     source: hosted
533
     source: hosted
331
     version: "0.2.0+1"
534
     version: "0.2.0+1"
535
+  yaml:
536
+    dependency: transitive
537
+    description:
538
+      name: yaml
539
+      url: "https://pub.flutter-io.cn"
540
+    source: hosted
541
+    version: "3.1.0"
332
 sdks:
542
 sdks:
333
   dart: ">=2.16.1 <3.0.0"
543
   dart: ">=2.16.1 <3.0.0"
334
   flutter: ">=2.8.1"
544
   flutter: ">=2.8.1"

+ 7
- 0
pubspec.yaml View File

40
   get_storage: ^2.0.3
40
   get_storage: ^2.0.3
41
   fluttertoast: ^8.0.9
41
   fluttertoast: ^8.0.9
42
   carousel_slider: ^4.0.0
42
   carousel_slider: ^4.0.0
43
+  amap_flutter_map: ^3.0.0
44
+  amap_flutter_location: ^3.0.0
45
+  permission_handler: ^9.2.0
43
 
46
 
47
+  json_serializable: ^6.1.5
44
 
48
 
45
 dev_dependencies:
49
 dev_dependencies:
46
   flutter_test:
50
   flutter_test:
53
   # rules and activating additional ones.
57
   # rules and activating additional ones.
54
   flutter_lints: ^1.0.0
58
   flutter_lints: ^1.0.0
55
   fluttertoast: ^8.0.9
59
   fluttertoast: ^8.0.9
60
+
61
+  json_serializable: ^6.1.5
62
+  flutter_screenutil: ^5.3.1
56
 # For information on the generic Dart part of this file, see the
63
 # For information on the generic Dart part of this file, see the
57
 # following pages: https://dart.dev/tools/pub/pubspec
64
 # following pages: https://dart.dev/tools/pub/pubspec
58
 
65