Skip to content

Commit f892244

Browse files
committed
fix: Updated new features for nullability
Features that were added before the pull request from @jonbhanson were updated to support nullability.
1 parent 40427ef commit f892244

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 1.0.0
22

3+
Tanks to @jonbhanson
34
* Adds null safety.
45
* Refreshes the example app.
56
* Updates .gitignore and removes files that should not be tracked.

example/lib/annotation_icons.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AnnotationIconsBodyState extends State<AnnotationIconsBody> {
5050
annotationId: AnnotationId("annotation_1"),
5151
anchor: Offset(0.5, -4),
5252
position: LatLng(52.707755, -2.7540658),
53-
icon: _annotationIcon!,
53+
icon: _annotationIcon ?? BitmapDescriptor.defaultAnnotation,
5454
),
5555
].toSet();
5656
}

example/lib/place_annotation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class PlaceAnnotationBodyState extends State<PlaceAnnotationBody> {
5757
final Annotation? tappedAnnotation = annotations[annotationId];
5858
if (tappedAnnotation != null) {
5959
setState(() {
60-
if (annotations.containsKey(selectedAnnotation)) {
60+
if (annotations.containsKey(tappedAnnotation)) {
6161
final Annotation resetOld =
6262
annotations[selectedAnnotation]!.copyWith();
6363
annotations[selectedAnnotation] = resetOld;

lib/src/controller.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,18 @@ class AppleMapController {
219219
return LatLngBounds(northeast: northeast, southwest: southwest);
220220
}
221221

222-
223222
/// A projection is used to translate between on screen location and geographic coordinates.
224223
/// Screen location is in screen pixels (not display pixels) with respect to the top left corner
225224
/// of the map, not necessarily of the whole screen.
226-
Future<Offset> getScreenCoordinate(LatLng latLng) async {
225+
Future<Offset?> getScreenCoordinate(LatLng latLng) async {
227226
final point = await channel
228-
.invokeMapMethod<String, dynamic>(
229-
'camera#convert', <String, dynamic>{
227+
.invokeMapMethod<String, dynamic>('camera#convert', <String, dynamic>{
230228
'annotation': [latLng.latitude, latLng.longitude]
231229
});
232-
if (!point.containsKey('point')) {
230+
if (point != null && !point.containsKey('point')) {
233231
return null;
234232
}
235-
final doubles = List<double>.from(point['point']);
233+
final doubles = List<double>.from(point?['point']);
236234
return Offset(doubles.first, doubles.last);
237235
}
238236
}

0 commit comments

Comments
 (0)