This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[google_maps_flutter] Fix CameraPosition regression (#3547)
The nullability conversion added a type check when recreating a CameraPosition from JSON that was too restrictive, and regressed the app-facing package. This relaxes that assertion, and adds a test to catch the issue.
- Loading branch information
1 parent
9136b68
commit 7a3b4ae
Showing
4 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 2.0.0-nullsafety.1 | ||
|
||
* Fix overly-restrictive type check. | ||
|
||
## 2.0.0-nullsafety | ||
|
||
* Migrated to null-safety. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...es/google_maps_flutter/google_maps_flutter_platform_interface/test/types/camera_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
test('toMap / fromMap', () { | ||
final cameraPosition = CameraPosition( | ||
target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, zoom: 1.5); | ||
// Cast to <dynamic, dynamic> to ensure that recreating from JSON, where | ||
// type information will have likely been lost, still works. | ||
final json = (cameraPosition.toMap() as Map<String, dynamic>) | ||
.cast<dynamic, dynamic>(); | ||
final cameraPositionFromJson = CameraPosition.fromMap(json); | ||
|
||
expect(cameraPosition, cameraPositionFromJson); | ||
}); | ||
} |