Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter] Fix CameraPosition regression #3547

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CameraPosition {
///
/// Mainly for internal use.
static CameraPosition? fromMap(Object? json) {
if (json == null || !(json is Map<String, dynamic>)) {
if (json == null || !(json is Map<dynamic, dynamic>)) {
return null;
}
final LatLng? target = LatLng.fromJson(json['target']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the google_maps_flutter plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.0.0-nullsafety
version: 2.0.0-nullsafety.1

dependencies:
flutter:
Expand Down
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);
});
}