From 8c59ec203aabeb11a747f0a095d07ef8fe63a0bd Mon Sep 17 00:00:00 2001 From: Kuloud Date: Sun, 25 Aug 2024 23:37:44 +0800 Subject: [PATCH] release: 1.0.11 --- CHANGELOG.md | 6 +++ README.md | 2 +- analysis_options.yaml | 1 + example/ios/Podfile.lock | 4 +- example/lib/widgets/amap_radio_group.dart | 4 +- lib/src/amap_initializer.dart | 2 +- lib/src/amap_widget.dart | 47 +++++++++++------------ lib/src/core/map_event.dart | 21 +++++----- lib/src/core/method_channel_amap_map.dart | 8 ++-- lib/src/types/base_overlay.dart | 2 +- lib/src/types/camera.dart | 2 +- lib/src/types/marker.dart | 7 ++-- lib/src/types/marker_updates.dart | 10 ----- lib/src/types/polygon.dart | 1 + lib/src/types/polygon_updates.dart | 22 +++-------- lib/src/types/polyline.dart | 10 ++--- lib/src/types/polyline_updates.dart | 22 +++-------- lib/src/types/ui.dart | 26 ++++++------- lib/src/utils/location_utils.dart | 2 +- pubspec.yaml | 6 +-- 20 files changed, 87 insertions(+), 118 deletions(-) create mode 100644 analysis_options.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bcd124..102a0f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ +## 1.0.11 +2024-08-25 +* 升级amap iOS sdk版本 10.0.900 | 2024-08-23 +* code lint + ## 1.0.10 2024-08-25 * 移除extension实现机制 * 添加 getMapContentApprovalNumber / getSatelliteImageApprovalNumber(参见example#ShowMapPage) * 添加 InfoWindowAdapter(参见example#CustomInfoWindowDemoPage),结合 infoWindowEnable 和 BaseInfoWindowAdapter 自行实现具体逻辑 +* permission_handler 11.3.0 -> 11.3.1 ## 1.0.9 2024-08-24 diff --git a/README.md b/README.md index c47687b..df136b7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ | | Android | iOS | | ----------- | -------------------------- | -------- | -| **AMapSDK** | 10.0.800_loc6.4.5_sea9.7.2 | 10.0.800 | +| **AMapSDK** | 10.0.800_loc6.4.5_sea9.7.2 | 10.0.900 | | **Support** | SDK 16+ | 12.0+ | 本插件基于 amap_flutter_map 3.0.0 进行二开的原因: diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..ea2c9e9 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3792267..f1a7b4c 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - AMap3DMap (10.0.800): + - AMap3DMap (10.0.900): - AMapFoundation (>= 1.8.0) - amap_map (1.0.8): - AMap3DMap @@ -28,7 +28,7 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler_apple/ios" SPEC CHECKSUMS: - AMap3DMap: 6761e0381f517978312e4f795ce77b2b9f6781a6 + AMap3DMap: 220e48934bc6553a15251c8c86f581a802787506 amap_map: 5be213f350872f6ea406be964031572ab9a0d6e1 AMapFoundation: 9885c48fc3a78fdfb84a0299a2293e56ea3c9fec Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 diff --git a/example/lib/widgets/amap_radio_group.dart b/example/lib/widgets/amap_radio_group.dart index 8a5b644..f83b5b2 100644 --- a/example/lib/widgets/amap_radio_group.dart +++ b/example/lib/widgets/amap_radio_group.dart @@ -24,13 +24,13 @@ class _AMapRadioGroupState extends State> { @override void initState() { super.initState(); - _groupValue = (widget.groupValue ?? null) as T?; + _groupValue = (widget.groupValue); } @override Widget build(BuildContext context) { List radioList = []; - _groupValue = (widget.groupValue ?? null) as T?; + _groupValue = (widget.groupValue); Widget _myRadio(String label, dynamic radioValue) { return Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/src/amap_initializer.dart b/lib/src/amap_initializer.dart index 1e7e995..7817d56 100644 --- a/lib/src/amap_initializer.dart +++ b/lib/src/amap_initializer.dart @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -part of amap_map; +part of '../amap_map.dart'; class AMapInitializer { static AMapApiKey? _apiKey; diff --git a/lib/src/amap_widget.dart b/lib/src/amap_widget.dart index 5505215..e7e34ce 100644 --- a/lib/src/amap_widget.dart +++ b/lib/src/amap_widget.dart @@ -10,9 +10,9 @@ // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, -part of amap_map; +part of '../amap_map.dart'; -typedef void MapCreatedCallback(AMapController controller); +typedef MapCreatedCallback = void Function(AMapController controller); ///用于展示高德地图的Widget class AMapWidget extends StatefulWidget { @@ -124,7 +124,7 @@ class AMapWidget extends StatefulWidget { /// /// [AssertionError] will be thrown if [initialCameraPosition] is null; const AMapWidget( - {Key? key, + {super.key, this.initialCameraPosition = const CameraPosition(target: LatLng(39.909187, 116.397451), zoom: 10), this.mapType = MapType.normal, @@ -157,8 +157,7 @@ class AMapWidget extends StatefulWidget { this.infoWindowAdapter, this.logoPosition, this.logoBottomMargin, - this.logoLeftMargin}) - : super(key: key); + this.logoLeftMargin}); /// @override @@ -169,7 +168,7 @@ class _MapState extends State { Map _markers = {}; Map _polylines = {}; Map _polygons = {}; - Map _infoWindows = {}; + final Map _infoWindows = {}; final Completer _controller = Completer(); late _AMapOptions _mapOptions; @@ -244,38 +243,38 @@ class _MapState extends State { ); _controller.complete(controller); - final MapCreatedCallback? _onMapCreated = widget.onMapCreated; - if (_onMapCreated != null) { - _onMapCreated(controller); + final MapCreatedCallback? onMapCreated = widget.onMapCreated; + if (onMapCreated != null) { + onMapCreated(controller); } } void onMarkerTap(String markerId) { - final Marker? _marker = _markers[markerId]; - if (_marker != null) { - final ArgumentCallback? _onTap = _marker.onTap; - if (_onTap != null) { - _onTap(markerId); + final Marker? marker = _markers[markerId]; + if (marker != null) { + final ArgumentCallback? onTap = marker.onTap; + if (onTap != null) { + onTap(markerId); } } } void onMarkerDragEnd(String markerId, LatLng position) { - final Marker? _marker = _markers[markerId]; - if (_marker != null) { - final MarkerDragEndCallback? _onDragEnd = _marker.onDragEnd; - if (_onDragEnd != null) { - _onDragEnd(markerId, position); + final Marker? marker = _markers[markerId]; + if (marker != null) { + final MarkerDragEndCallback? onDragEnd = marker.onDragEnd; + if (onDragEnd != null) { + onDragEnd(markerId, position); } } } void onPolylineTap(String polylineId) { - final Polyline? _polyline = _polylines[polylineId]; - if (_polyline != null) { - final ArgumentCallback? _onTap = _polyline.onTap; - if (_onTap != null) { - _onTap(polylineId); + final Polyline? polyline = _polylines[polylineId]; + if (polyline != null) { + final ArgumentCallback? onTap = polyline.onTap; + if (onTap != null) { + onTap(polylineId); } } } diff --git a/lib/src/core/map_event.dart b/lib/src/core/map_event.dart index a6a881f..a52cece 100644 --- a/lib/src/core/map_event.dart +++ b/lib/src/core/map_event.dart @@ -18,29 +18,27 @@ class MapEvent { ///定位回调接口 class LocationChangedEvent extends MapEvent { - LocationChangedEvent(int mapId, AMapLocation value) : super(mapId, value); + LocationChangedEvent(super.mapId, super.value); } ///地图移动回调 class CameraPositionMoveEvent extends MapEvent { - CameraPositionMoveEvent(int mapId, CameraPosition value) - : super(mapId, value); + CameraPositionMoveEvent(super.mapId, super.value); } ///地图移动结束回调 class CameraPositionMoveEndEvent extends MapEvent { - CameraPositionMoveEndEvent(int mapId, CameraPosition value) - : super(mapId, value); + CameraPositionMoveEndEvent(super.mapId, super.value); } ///点击地图回调 class MapTapEvent extends MapEvent { - MapTapEvent(int mapId, LatLng value) : super(mapId, value); + MapTapEvent(super.mapId, super.value); } ///长按地图回调 class MapLongPressEvent extends MapEvent { - MapLongPressEvent(int mapId, LatLng value) : super(mapId, value); + MapLongPressEvent(super.mapId, super.value); } /// 带位置回调的地图事件 @@ -57,21 +55,20 @@ class _PositionedMapEvent extends MapEvent { /// [Marker] 的点击事件 class MarkerTapEvent extends MapEvent { - MarkerTapEvent(int mapId, String markerId) : super(mapId, markerId); + MarkerTapEvent(super.mapId, super.markerId); } /// [Marker] 的拖拽结束事件,附带拖拽结束时的位置信息[LatLng]. class MarkerDragEndEvent extends _PositionedMapEvent { - MarkerDragEndEvent(int mapId, LatLng position, String markerId) - : super(mapId, position, markerId); + MarkerDragEndEvent(super.mapId, super.position, super.markerId); } /// [Polyline] 的点击事件 class PolylineTapEvent extends MapEvent { - PolylineTapEvent(int mapId, String polylineId) : super(mapId, polylineId); + PolylineTapEvent(super.mapId, super.polylineId); } /// Poi点击事件 class MapPoiTouchEvent extends MapEvent { - MapPoiTouchEvent(int mapId, AMapPoi poi) : super(mapId, poi); + MapPoiTouchEvent(super.mapId, super.poi); } diff --git a/lib/src/core/method_channel_amap_map.dart b/lib/src/core/method_channel_amap_map.dart index 7b6f84a..d1d35ae 100644 --- a/lib/src/core/method_channel_amap_map.dart +++ b/lib/src/core/method_channel_amap_map.dart @@ -182,7 +182,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { _mapEventStreamController.add(LocationChangedEvent( mapId, AMapLocation.fromMap(call.arguments['location'])!)); } catch (e) { - print("location#changed error=======>" + e.toString()); + print("location#changed error=======>$e"); } break; @@ -191,7 +191,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { _mapEventStreamController.add(CameraPositionMoveEvent( mapId, CameraPosition.fromMap(call.arguments['position'])!)); } catch (e) { - print("camera#onMove error===>" + e.toString()); + print("camera#onMove error===>$e"); } break; case 'camera#onMoveEnd': @@ -199,7 +199,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { _mapEventStreamController.add(CameraPositionMoveEndEvent( mapId, CameraPosition.fromMap(call.arguments['position'])!)); } catch (e) { - print("camera#onMoveEnd error===>" + e.toString()); + print("camera#onMoveEnd error===>$e"); } break; case 'map#onTap': @@ -232,7 +232,7 @@ class MethodChannelAMapFlutterMap implements AMapFlutterPlatform { _mapEventStreamController.add(MapPoiTouchEvent( mapId, AMapPoi.fromJson(call.arguments['poi'])!)); } catch (e) { - print('map#onPoiTouched error===>' + e.toString()); + print('map#onPoiTouched error===>$e'); } break; } diff --git a/lib/src/types/base_overlay.dart b/lib/src/types/base_overlay.dart index f8dbf47..122749b 100644 --- a/lib/src/types/base_overlay.dart +++ b/lib/src/types/base_overlay.dart @@ -6,7 +6,7 @@ class BaseOverlay { String get id => _id; BaseOverlay() { - this._id = this.hashCode.toString(); + _id = hashCode.toString(); } void setIdForCopy(String copyId) => _id = copyId; diff --git a/lib/src/types/camera.dart b/lib/src/types/camera.dart index ebb148d..d435327 100644 --- a/lib/src/types/camera.dart +++ b/lib/src/types/camera.dart @@ -38,7 +38,7 @@ class CameraPosition { /// /// 主要在插件内部使用 static CameraPosition? fromMap(dynamic json) { - if (json == null || !(json is Map)) { + if (json == null || json is! Map) { return null; } final LatLng? target = LatLng.fromJson(json['target']); diff --git a/lib/src/types/marker.dart b/lib/src/types/marker.dart index 82f3415..1a06bd0 100644 --- a/lib/src/types/marker.dart +++ b/lib/src/types/marker.dart @@ -8,7 +8,7 @@ import 'package:x_amap_base/x_amap_base.dart'; import 'bitmap.dart'; /// Marker拖动回调 -typedef void MarkerDragEndCallback(String id, LatLng endPosition); +typedef MarkerDragEndCallback = void Function(String id, LatLng endPosition); ///Marker的气泡 /// @@ -91,11 +91,11 @@ class Marker extends BaseOverlay { this.zIndex = 0.0, this.onTap, this.onDragEnd, - }) : this.alpha = + }) : alpha = // ignore: unnecessary_null_comparison (alpha != null ? (alpha < 0 ? 0 : (alpha > 1 ? 1 : alpha)) : alpha), // ignore: unnecessary_null_comparison - this.anchor = (anchor == null + anchor = (anchor == null ? Offset(0.5, 1.0) : ((anchor.dx < 0 || anchor.dx > 1 || @@ -182,6 +182,7 @@ class Marker extends BaseOverlay { return copyMark; } + @override Marker clone() => copyWith(); @override diff --git a/lib/src/types/marker_updates.dart b/lib/src/types/marker_updates.dart index 84212d3..f7cc11f 100644 --- a/lib/src/types/marker_updates.dart +++ b/lib/src/types/marker_updates.dart @@ -6,16 +6,6 @@ import 'types.dart'; class MarkerUpdates { /// 根据之前的marker列表[previous]和当前的marker列表[current]创建[MakerUpdates]. MarkerUpdates.from(Set previous, Set current) { - // ignore: unnecessary_null_comparison - if (previous == null) { - previous = Set.identity(); - } - - // ignore: unnecessary_null_comparison - if (current == null) { - current = Set.identity(); - } - final Map previousMarkers = keyByMarkerId(previous); final Map currentMarkers = keyByMarkerId(current); diff --git a/lib/src/types/polygon.dart b/lib/src/types/polygon.dart index 7fa4f27..693ef2c 100644 --- a/lib/src/types/polygon.dart +++ b/lib/src/types/polygon.dart @@ -60,6 +60,7 @@ class Polygon extends BaseOverlay { return copyPolyline; } + @override Polygon clone() => copyWith(); /// 转换成可以序列化的map diff --git a/lib/src/types/polygon_updates.dart b/lib/src/types/polygon_updates.dart index fd7be07..49d2777 100644 --- a/lib/src/types/polygon_updates.dart +++ b/lib/src/types/polygon_updates.dart @@ -9,16 +9,6 @@ import 'types.dart'; class PolygonUpdates { /// 通过Polygon的前后更新集合构造一个PolygonUpdates PolygonUpdates.from(Set previous, Set current) { - // ignore: unnecessary_null_comparison - if (previous == null) { - previous = Set.identity(); - } - - // ignore: unnecessary_null_comparison - if (current == null) { - current = Set.identity(); - } - final Map previousPolygons = keyByPolygonId(previous); final Map currentPolygons = keyByPolygonId(current); @@ -29,10 +19,10 @@ class PolygonUpdates { return currentPolygons[id]!; } - final Set _polygonIdsToRemove = + final Set tempPolygonIdsToRemove = prevPolygonIds.difference(currentPolygonIds); - final Set _polygonsToAdd = currentPolygonIds + final Set tempPolygonsToAdd = currentPolygonIds .difference(prevPolygonIds) .map(idToCurrentPolygon) .toSet(); @@ -42,15 +32,15 @@ class PolygonUpdates { return current != previous; } - final Set _polygonsToChange = currentPolygonIds + final Set tempPolygonsToChange = currentPolygonIds .intersection(prevPolygonIds) .map(idToCurrentPolygon) .where(hasChanged) .toSet(); - polygonsToAdd = _polygonsToAdd; - polygonIdsToRemove = _polygonIdsToRemove; - polygonsToChange = _polygonsToChange; + polygonsToAdd = tempPolygonsToAdd; + polygonIdsToRemove = tempPolygonIdsToRemove; + polygonsToChange = tempPolygonsToChange; } /// 想要添加的polygon对象集合. diff --git a/lib/src/types/polyline.dart b/lib/src/types/polyline.dart index a50e874..876923e 100644 --- a/lib/src/types/polyline.dart +++ b/lib/src/types/polyline.dart @@ -62,9 +62,9 @@ class Polyline extends BaseOverlay { this.customTexture, this.onTap, this.color = const Color(0xCCC4E0F0), - }) : assert(points.length > 0), - this.width = (width <= 0 ? 10 : width), - this.alpha = (alpha < 0 ? 0 : (alpha > 1 ? 1 : alpha)), + }) : assert(points.isNotEmpty), + width = (width <= 0 ? 10 : width), + alpha = (alpha < 0 ? 0 : (alpha > 1 ? 1 : alpha)), super(); /// 覆盖物的坐标点数组,points不能为空 @@ -131,6 +131,7 @@ class Polyline extends BaseOverlay { return copyPolyline; } + @override Polyline clone() => copyWith(); /// 将对象转换为可序列化的map. @@ -176,9 +177,6 @@ class Polyline extends BaseOverlay { color == typedOther.color; } - @override - int get hashCode => super.hashCode; - dynamic _pointsToJson() { final List result = []; for (final LatLng point in points) { diff --git a/lib/src/types/polyline_updates.dart b/lib/src/types/polyline_updates.dart index 174b469..27e36b2 100644 --- a/lib/src/types/polyline_updates.dart +++ b/lib/src/types/polyline_updates.dart @@ -10,16 +10,6 @@ import 'types.dart'; class PolylineUpdates { /// 通过polyline的前后更新集合构造一个polylineUpdates PolylineUpdates.from(Set previous, Set current) { - // ignore: unnecessary_null_comparison - if (previous == null) { - previous = Set.identity(); - } - - // ignore: unnecessary_null_comparison - if (current == null) { - current = Set.identity(); - } - final Map previousPolylines = keyByPolylineId(previous); final Map currentPolylines = keyByPolylineId(current); @@ -30,10 +20,10 @@ class PolylineUpdates { return currentPolylines[id]!; } - final Set _polylineIdsToRemove = + final Set tempPolylineIdsToRemove = prevPolylineIds.difference(currentPolylineIds); - final Set _polylinesToAdd = currentPolylineIds + final Set tempPolylinesToAdd = currentPolylineIds .difference(prevPolylineIds) .map(idToCurrentPolyline) .toSet(); @@ -43,15 +33,15 @@ class PolylineUpdates { return current != previous; } - final Set _polylinesToChange = currentPolylineIds + final Set tempPolylinesToChange = currentPolylineIds .intersection(prevPolylineIds) .map(idToCurrentPolyline) .where(hasChanged) .toSet(); - polylinesToAdd = _polylinesToAdd; - polylineIdsToRemove = _polylineIdsToRemove; - polylinesToChange = _polylinesToChange; + polylinesToAdd = tempPolylinesToAdd; + polylineIdsToRemove = tempPolylineIdsToRemove; + polylinesToChange = tempPolylinesToChange; } /// 用于添加polyline的集合 diff --git a/lib/src/types/ui.dart b/lib/src/types/ui.dart index 3af977d..48baf40 100644 --- a/lib/src/types/ui.dart +++ b/lib/src/types/ui.dart @@ -72,14 +72,12 @@ class MinMaxZoomPreference { /// 缩放级别范围为[3, 20],超出范围取边界值 /// const MinMaxZoomPreference(double minZoom, double maxZoom) - : this.minZoom = - ((minZoom < 3 ? 3 : minZoom) > (maxZoom > 20 ? 20 : maxZoom) - ? maxZoom - : minZoom), - this.maxZoom = - ((minZoom < 3 ? 3 : minZoom) > (maxZoom > 20 ? 20 : maxZoom) - ? minZoom - : maxZoom); + : minZoom = ((minZoom < 3 ? 3 : minZoom) > (maxZoom > 20 ? 20 : maxZoom) + ? maxZoom + : minZoom), + maxZoom = ((minZoom < 3 ? 3 : minZoom) > (maxZoom > 20 ? 20 : maxZoom) + ? minZoom + : maxZoom); /// 最小zoomLevel final double? minZoom; @@ -152,10 +150,10 @@ class MyLocationStyleOptions { } return MyLocationStyleOptions( json['enabled'] ?? false, - circleFillColor: json['circleFillColor'] ?? null, - circleStrokeColor: json['circleStrokeColor'] ?? null, - circleStrokeWidth: json['circleStrokeWidth'] ?? null, - icon: json['icon'] ?? null, + circleFillColor: json['circleFillColor'], + circleStrokeColor: json['circleStrokeColor'], + circleStrokeWidth: json['circleStrokeWidth'], + icon: json['icon'], ); } @@ -225,8 +223,8 @@ class CustomStyleOptions { } return CustomStyleOptions( json['enabled'] ?? false, - styleData: json['styleData'] ?? null, - styleExtraData: json['styleExtraData'] ?? null, + styleData: json['styleData'], + styleExtraData: json['styleExtraData'], ); } diff --git a/lib/src/utils/location_utils.dart b/lib/src/utils/location_utils.dart index 04a161d..893a6bb 100644 --- a/lib/src/utils/location_utils.dart +++ b/lib/src/utils/location_utils.dart @@ -1,4 +1,4 @@ -part of amap_map; +part of '../../amap_map.dart'; bool isLocationValid(AMapLocation location) { final LatLng latLng = location.latLng; diff --git a/pubspec.yaml b/pubspec.yaml index 1b4061b..36b9381 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: amap_map description: Amap SDK Flutter plugin for integrating AMapSDK in iOS and Android applications. -version: 1.0.10 +version: 1.0.11 homepage: https://github.com/kuloud/amap_map issue_tracker: https://github.com/kuloud/amap_map/issues platforms: @@ -24,13 +24,11 @@ dependencies: x_amap_base: ^1.0.3 x_common: ^1.0.4 - # provider: ^6.1.1 - # x_amap_base: - # path: ../x_amap_base dev_dependencies: flutter_test: sdk: flutter + lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec