From f8922443b443ce133c76644d2e98cd8f1777a625 Mon Sep 17 00:00:00 2001 From: Luis Thein Date: Sun, 28 Mar 2021 13:16:54 +0200 Subject: [PATCH] fix: Updated new features for nullability Features that were added before the pull request from @jonbhanson were updated to support nullability. --- CHANGELOG.md | 1 + example/lib/annotation_icons.dart | 2 +- example/lib/place_annotation.dart | 2 +- lib/src/controller.dart | 10 ++++------ 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f91933..e00f936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 1.0.0 +Tanks to @jonbhanson * Adds null safety. * Refreshes the example app. * Updates .gitignore and removes files that should not be tracked. diff --git a/example/lib/annotation_icons.dart b/example/lib/annotation_icons.dart index e89d83e..6282128 100644 --- a/example/lib/annotation_icons.dart +++ b/example/lib/annotation_icons.dart @@ -50,7 +50,7 @@ class AnnotationIconsBodyState extends State { annotationId: AnnotationId("annotation_1"), anchor: Offset(0.5, -4), position: LatLng(52.707755, -2.7540658), - icon: _annotationIcon!, + icon: _annotationIcon ?? BitmapDescriptor.defaultAnnotation, ), ].toSet(); } diff --git a/example/lib/place_annotation.dart b/example/lib/place_annotation.dart index ddb0fcf..09b0738 100644 --- a/example/lib/place_annotation.dart +++ b/example/lib/place_annotation.dart @@ -57,7 +57,7 @@ class PlaceAnnotationBodyState extends State { final Annotation? tappedAnnotation = annotations[annotationId]; if (tappedAnnotation != null) { setState(() { - if (annotations.containsKey(selectedAnnotation)) { + if (annotations.containsKey(tappedAnnotation)) { final Annotation resetOld = annotations[selectedAnnotation]!.copyWith(); annotations[selectedAnnotation] = resetOld; diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 906d324..79459b2 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -219,20 +219,18 @@ class AppleMapController { return LatLngBounds(northeast: northeast, southwest: southwest); } - /// A projection is used to translate between on screen location and geographic coordinates. /// Screen location is in screen pixels (not display pixels) with respect to the top left corner /// of the map, not necessarily of the whole screen. - Future getScreenCoordinate(LatLng latLng) async { + Future getScreenCoordinate(LatLng latLng) async { final point = await channel - .invokeMapMethod( - 'camera#convert', { + .invokeMapMethod('camera#convert', { 'annotation': [latLng.latitude, latLng.longitude] }); - if (!point.containsKey('point')) { + if (point != null && !point.containsKey('point')) { return null; } - final doubles = List.from(point['point']); + final doubles = List.from(point?['point']); return Offset(doubles.first, doubles.last); } }