From b1a3199a46512fc6a12813fb00d65bcb7afbaf2a Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Sat, 18 Jan 2020 22:42:03 +0800 Subject: [PATCH 01/13] Fix ios crash problem when fields of regeocode is nil. --- ios/Classes/AmapLocationPlugin.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ios/Classes/AmapLocationPlugin.m b/ios/Classes/AmapLocationPlugin.m index ae0f1c2..70aa818 100644 --- a/ios/Classes/AmapLocationPlugin.m +++ b/ios/Classes/AmapLocationPlugin.m @@ -197,17 +197,17 @@ +(id)checkNull:(NSObject*)value{ } +(NSDictionary*)regeocode2map:(AMapLocationReGeocode *)regeocode{ - return @{@"formattedAddress":regeocode.formattedAddress, - @"country":regeocode.country, - @"province":regeocode.province, - @"city":regeocode.city, - @"district":regeocode.district, - @"citycode":regeocode.citycode, - @"adcode":regeocode.adcode, - @"street":regeocode.street, - @"number":regeocode.number, + return @{@"formattedAddress":[self checkNull : regeocode.formattedAddress], + @"country":[self checkNull : regeocode.country], + @"province":[self checkNull : regeocode.province], + @"city":[self checkNull : regeocode.city], + @"district":[self checkNull : regeocode.district], + @"citycode":[self checkNull : regeocode.citycode], + @"adcode":[self checkNull : regeocode.adcode], + @"street":[self checkNull : regeocode.street], + @"number":[self checkNull : regeocode.number], @"POIName":[self checkNull : regeocode.POIName], - @"AOIName":[self checkNull :regeocode.AOIName], + @"AOIName":[self checkNull : regeocode.AOIName], }; } From 33cb0f34f2a49711bfd4165883e7cde7ba18be96 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Tue, 15 Jun 2021 13:49:09 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=95=8F=E6=84=9F=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/src/main/AndroidManifest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index fae818d..26c8f56 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ - + @@ -28,10 +28,10 @@ - + - + From a3a6791fdac608cf40cfba516f5fd55f8180bd01 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Sat, 25 Sep 2021 22:31:06 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/src/main/AndroidManifest.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 26c8f56..c1a5098 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -12,9 +12,6 @@ - - - @@ -27,12 +24,6 @@ - - - - - - From 81372d5725b9e55f83f6be60b4acf658cd9d64ac Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Sun, 26 Sep 2021 13:51:05 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/src/main/AndroidManifest.xml | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index c1a5098..61e6fbf 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,17 +1,24 @@ - - - - - - - + + - - + + + + + + + + + + + + + + @@ -19,10 +26,6 @@ - - - - From 40368a4a4d93ee5e54f0d7cd154dc82a9e986d4a Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 11:16:19 +0800 Subject: [PATCH 05/13] Supporting the new Android plugins APIs https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration --- .../jzoom/amaplocation/AmapLocationPlugin.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index f365553..97d5b86 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -5,6 +5,8 @@ import android.content.Intent; import android.util.Log; +import androidx.annotation.NonNull; + import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; @@ -13,6 +15,7 @@ import java.util.HashMap; import java.util.Map; +import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; @@ -22,7 +25,7 @@ /** * FlutterAmapLocationPlugin */ -public class AmapLocationPlugin implements MethodCallHandler, AMapLocationListener { +public class AmapLocationPlugin implements FlutterPlugin, MethodCallHandler, AMapLocationListener { private Registrar registrar; @@ -54,6 +57,17 @@ public static void registerWith(Registrar registrar) { channel.setMethodCallHandler(new AmapLocationPlugin(registrar,channel)); } + @Override + public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { + channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "amap_location"); + channel.setMethodCallHandler(this); + } + + @Override + public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { + channel.setMethodCallHandler(null); + } + @Override public void onMethodCall(MethodCall call, Result result) { String method = call.method; From 575a4ed718b6fe92b0d7ba7e5e2e617c23cd4093 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 11:19:38 +0800 Subject: [PATCH 06/13] version: 0.2.1 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index df12555..da7b07c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: amap_location description: AMap location plugin for flutter.高德地图定位插件 -version: 0.2.0 +version: 0.2.1 author: JZoom homepage: https://github.com/best-flutter/flutter_amap_location From 9d72d9daaa801e4fe72b78e2d4c2218a81cd36a7 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 12:37:37 +0800 Subject: [PATCH 07/13] fix --- .../main/java/com/jzoom/amaplocation/AmapLocationPlugin.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index 97d5b86..7051180 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -36,6 +36,10 @@ public class AmapLocationPlugin implements FlutterPlugin, MethodCallHandler, AMa //备份至 private boolean onceLocation; + public AmapLocationPlugin() { + + } + public AmapLocationPlugin(Registrar registrar, MethodChannel channel) { this.registrar = registrar; this.channel = channel; From 4f559957940029839025f589215b887066a9729b Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 12:46:14 +0800 Subject: [PATCH 08/13] wip --- .../amaplocation/AmapLocationPlugin.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index 7051180..b8a2572 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -36,31 +36,6 @@ public class AmapLocationPlugin implements FlutterPlugin, MethodCallHandler, AMa //备份至 private boolean onceLocation; - public AmapLocationPlugin() { - - } - - public AmapLocationPlugin(Registrar registrar, MethodChannel channel) { - this.registrar = registrar; - this.channel = channel; - } - - private Activity getActivity(){ - return registrar.activity(); - } - - private Context getApplicationContext(){ - return registrar.activity().getApplicationContext(); - } - - /** - * Plugin registration. - */ - public static void registerWith(Registrar registrar) { - final MethodChannel channel = new MethodChannel(registrar.messenger(), "amap_location"); - channel.setMethodCallHandler(new AmapLocationPlugin(registrar,channel)); - } - @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "amap_location"); From a8dfd69790e8eee3721a08687770c90065802d2d Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 12:50:15 +0800 Subject: [PATCH 09/13] wip --- .../java/com/jzoom/amaplocation/AmapLocationPlugin.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index b8a2572..58cac1f 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -27,8 +27,7 @@ */ public class AmapLocationPlugin implements FlutterPlugin, MethodCallHandler, AMapLocationListener { - - private Registrar registrar; + private Context context; private MethodChannel channel; private AMapLocationClientOption option; private AMapLocationClient locationClient; @@ -36,8 +35,13 @@ public class AmapLocationPlugin implements FlutterPlugin, MethodCallHandler, AMa //备份至 private boolean onceLocation; + private Context getApplicationContext(){ + return context; + } + @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { + context = flutterPluginBinding.getApplicationContext() channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "amap_location"); channel.setMethodCallHandler(this); } From 4fce86fb9a343b397f58714166efb4da81f7e153 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 18 Oct 2021 12:51:17 +0800 Subject: [PATCH 10/13] wip --- .../main/java/com/jzoom/amaplocation/AmapLocationPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index 58cac1f..676e40b 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -41,7 +41,7 @@ private Context getApplicationContext(){ @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { - context = flutterPluginBinding.getApplicationContext() + context = flutterPluginBinding.getApplicationContext(); channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "amap_location"); channel.setMethodCallHandler(this); } From 8cd103cf2484ff5306c85e49ad7262addc93de50 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Thu, 11 Nov 2021 20:37:53 +0800 Subject: [PATCH 11/13] migrate to null safety --- .idea/libraries/Dart_SDK.xml | 31 +++++--- .idea/misc.xml | 3 + .idea/workspace.xml | 134 +++++----------------------------- example/pubspec.lock | 115 +++++++++++++++-------------- example/test/widget_test.dart | 10 --- lib/amap_location.dart | 72 +++++++++--------- pubspec.lock | 99 +++++++++++++------------ pubspec.yaml | 4 +- 8 files changed, 193 insertions(+), 275 deletions(-) diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 198919e..6068110 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,17 +1,26 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 14a9642..b0ccf1a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5cb156f..b00606e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,115 +1,25 @@ + + - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -131,6 +41,7 @@ + @@ -154,26 +65,20 @@ + + + - - - + @@ -217,9 +122,6 @@ - - diff --git a/example/pubspec.lock b/example/pubspec.lock index 95e34e6..b8f78e0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: amap_location: dependency: "direct dev" @@ -7,56 +7,77 @@ packages: path: ".." relative: true source: path - version: "0.2.0" + version: "0.2.1" async: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.8.1" async_loader: dependency: "direct main" description: name: async_loader - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.2" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "0.1.3" easy_alert: dependency: "direct main" description: name: easy_alert - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" source: hosted - version: "0.0.2" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -71,42 +92,28 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.3+1" + version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.6.2" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.1" + version: "1.8.0" simple_permissions: dependency: "direct main" description: name: simple_permissions - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted version: "0.1.9" sky_engine: @@ -118,58 +125,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.5.4" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.2" + version: "0.4.2" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.1.0 <3.0.0" - flutter: ">=0.1.4 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=0.1.4" diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index c80c84c..fff8a24 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -12,16 +12,6 @@ import 'package:amap_location_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data.startsWith('Running on:'), - ), - findsOneWidget, - ); }); } diff --git a/lib/amap_location.dart b/lib/amap_location.dart index 5a7cd9b..9ad1f16 100644 --- a/lib/amap_location.dart +++ b/lib/amap_location.dart @@ -12,18 +12,18 @@ class AMapLocationQualityReport { static const int modeSaving = 3; static const int noGpsPermission = 4; - final bool wifiAble; + final bool? wifiAble; - final int gpsStatus; + final int? gpsStatus; - final int gpsSatellites; + final int? gpsSatellites; - final String networkType; + final String? networkType; //整数部分为秒,浮点部分为毫秒 - final double netUseTime; + final double? netUseTime; - final String adviseMessage; + final String? adviseMessage; AMapLocationQualityReport({ this.wifiAble, @@ -36,24 +36,24 @@ class AMapLocationQualityReport { } class AMapLocation { - final double accuracy; - final double altitude; - final double speed; - final double timestamp; - final double latitude; - final double longitude; - - final String formattedAddress; - final String country; - final String province; - final String city; - final String district; - final String citycode; - final String adcode; - final String street; - final String number; - final String POIName; - final String AOIName; + final double? accuracy; + final double? altitude; + final double? speed; + final double? timestamp; + final double? latitude; + final double? longitude; + + final String? formattedAddress; + final String? country; + final String? province; + final String? city; + final String? district; + final String? citycode; + final String? adcode; + final String? street; + final String? number; + final String? POIName; + final String? AOIName; // 这个参数很重要,在anroid和ios下的判断标准不一样 // android下: 0 定位成功。 @@ -85,19 +85,19 @@ class AMapLocation { // AMapLocationErrorRegionMonitoringFailure=10,///<地理围栏错误 // AMapLocationErrorRiskOfFakeLocation = 11, ///<存在虚拟定位风险 // }; - final int code; + final int? code; /// 描述 - final String description; + final String? description; ///这个字段用来判断有没有定位成功,在ios下,有可能获取到了经纬度,但是详细地址没有获取到, /// 这个情况下,值也为true - final bool success; + final bool? success; /// 以下属性为anroid特有 - final String provider; + final String? provider; - final int locationType; + final int? locationType; AMapLocation( {this.description, @@ -150,7 +150,7 @@ class AMapLocation { } /// 是否成功,单纯从经纬度来判断 - bool isSuccess() { + bool? isSuccess() { //code > 0 ,有可能是逆地理位置有错误,那么这个时候仍然是成功的 return success; } @@ -172,7 +172,7 @@ class AMapLocationClient { _locationUpdateStreamController.stream; /// 设置ios的key,android可以直接在配置文件中设置 - static Future setApiKey(String key) async { + static Future setApiKey(String key) async { return await _channel.invokeMethod("setApiKey", key); } @@ -186,27 +186,27 @@ class AMapLocationClient { /// 启动系统 /// @param options 启动系统所需选项 - static Future startup(AMapLocationOption option) async { + static Future startup(AMapLocationOption option) async { _channel.setMethodCallHandler(handler); return await _channel.invokeMethod("startup", option.toMap()); } /// 更新选项,如果已经在监听,那么要先停止监听,再调用这个函数 - static Future updateOption(AMapLocationOption option) async { + static Future updateOption(AMapLocationOption option) async { return await _channel.invokeMethod("updateOption", option); } - static Future shutdown() async { + static Future shutdown() async { return await _channel.invokeMethod("shutdown"); } /// 启动监听位置改变 - static Future startLocation() async { + static Future startLocation() async { return await _channel.invokeMethod("startLocation"); } /// 停止监听位置改变 - static Future stopLocation() async { + static Future stopLocation() async { return await _channel.invokeMethod("stopLocation"); } diff --git a/pubspec.lock b/pubspec.lock index 66e522a..8077d23 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,34 +1,55 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: async: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.8.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -43,37 +64,23 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.3+1" + version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.7.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -83,57 +90,57 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.5.4" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.2" + version: "0.4.2" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" sdks: - dart: ">=2.1.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index da7b07c..5a1c299 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: amap_location description: AMap location plugin for flutter.高德地图定位插件 -version: 0.2.1 +version: 0.2.2 author: JZoom homepage: https://github.com/best-flutter/flutter_amap_location environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: From bad387470e7bde401bce2f1bda0922a13ff44a6c Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Fri, 12 Nov 2021 21:44:44 +0800 Subject: [PATCH 12/13] handle exception --- .../amaplocation/AmapLocationPlugin.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java index 676e40b..c1fdfce 100644 --- a/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java +++ b/android/src/main/java/com/jzoom/amaplocation/AmapLocationPlugin.java @@ -219,18 +219,22 @@ private boolean startLocation(AMapLocationListener listener){ private boolean startup(Map arguments) { synchronized (this){ - if(locationClient==null){ - //初始化client - locationClient = new AMapLocationClient(getApplicationContext()); - //设置定位参数 - AMapLocationClientOption option = new AMapLocationClientOption(); - parseOptions(option,arguments); - locationClient.setLocationOption(option); - - //将option保存一下 - this.option = option; - - return true; + try { + if (locationClient == null) { + //初始化client + locationClient = new AMapLocationClient(getApplicationContext()); + //设置定位参数 + AMapLocationClientOption option = new AMapLocationClientOption(); + parseOptions(option, arguments); + locationClient.setLocationOption(option); + + //将option保存一下 + this.option = option; + + return true; + } + } catch (Exception e) { + return false; } return false; From 84f800bd5c3001a48909c58b89d2059ba46ef206 Mon Sep 17 00:00:00 2001 From: Daniel Dai Date: Mon, 15 Nov 2021 10:29:58 +0800 Subject: [PATCH 13/13] com.amap.api:location:5.5.1 --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 916149d..a3e5652 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -34,5 +34,5 @@ android { } dependencies { - implementation 'com.amap.api:location:latest.integration' + implementation 'com.amap.api:location:5.5.1' }