From 341e8a56d0eea6676aeff864775a2d85e8f1e9a3 Mon Sep 17 00:00:00 2001
From: Pau Picas
Date: Tue, 23 Jul 2019 15:38:03 +0200
Subject: [PATCH 1/4] [google_maps_flutter] Avoid unnecessary redraws
---
AUTHORS | 1 +
packages/google_maps_flutter/CHANGELOG.md | 4 ++++
packages/google_maps_flutter/lib/src/circle.dart | 11 ++++++++++-
.../lib/src/circle_updates.dart | 4 ++++
packages/google_maps_flutter/lib/src/marker.dart | 14 +++++++++++++-
.../lib/src/marker_updates.dart | 4 ++++
packages/google_maps_flutter/lib/src/polygon.dart | 11 ++++++++++-
.../lib/src/polygon_updates.dart | 4 ++++
packages/google_maps_flutter/lib/src/polyline.dart | 14 +++++++++++++-
.../lib/src/polyline_updates.dart | 4 ++++
packages/google_maps_flutter/pubspec.yaml | 2 +-
11 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index a24dfd196966..ed6942ae1a6e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -43,3 +43,4 @@ Audrius Karosevicius
Lukasz Piliszczuk
SoundReply Solutions GmbH
Rafal Wachol
+Pau Picas
\ No newline at end of file
diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md
index 2f5983e0cbcf..199064ec6502 100644
--- a/packages/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.20+7
+
+* Don't recreate map elements if they didn't change since las widget build.
+
## 0.5.20+6
* Adds support for toggling the traffic layer
diff --git a/packages/google_maps_flutter/lib/src/circle.dart b/packages/google_maps_flutter/lib/src/circle.dart
index d09d3c492a75..eefb8c021fa6 100644
--- a/packages/google_maps_flutter/lib/src/circle.dart
+++ b/packages/google_maps_flutter/lib/src/circle.dart
@@ -141,7 +141,16 @@ class Circle {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final Circle typedOther = other;
- return circleId == typedOther.circleId;
+ return circleId == typedOther.circleId &&
+ consumeTapEvents == typedOther.consumeTapEvents &&
+ fillColor == typedOther.fillColor &&
+ center == typedOther.center &&
+ radius == typedOther.radius &&
+ strokeColor == typedOther.strokeColor &&
+ strokeWidth == typedOther.strokeWidth &&
+ visible == typedOther.visible &&
+ zIndex == typedOther.zIndex &&
+ onTap == typedOther.onTap;
}
@override
diff --git a/packages/google_maps_flutter/lib/src/circle_updates.dart b/packages/google_maps_flutter/lib/src/circle_updates.dart
index 5dddb3a8ad15..416e30356754 100644
--- a/packages/google_maps_flutter/lib/src/circle_updates.dart
+++ b/packages/google_maps_flutter/lib/src/circle_updates.dart
@@ -39,6 +39,10 @@ class _CircleUpdates {
final Set _circlesToChange = currentCircleIds
.intersection(prevCircleIds)
.map(idToCurrentCircle)
+ .where((Circle _current) {
+ final Circle _previous = previousCircles[_current.circleId];
+ return _current != _previous;
+ })
.toSet();
circlesToAdd = _circlesToAdd;
diff --git a/packages/google_maps_flutter/lib/src/marker.dart b/packages/google_maps_flutter/lib/src/marker.dart
index 1f64f0ee19ff..4a087f797cdf 100644
--- a/packages/google_maps_flutter/lib/src/marker.dart
+++ b/packages/google_maps_flutter/lib/src/marker.dart
@@ -283,7 +283,19 @@ class Marker {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final Marker typedOther = other;
- return markerId == typedOther.markerId;
+ return markerId == typedOther.markerId &&
+ alpha == typedOther.alpha &&
+ anchor == typedOther.anchor &&
+ consumeTapEvents == typedOther.consumeTapEvents &&
+ draggable == typedOther.draggable &&
+ flat == typedOther.flat &&
+ icon == typedOther.icon &&
+ infoWindow == typedOther.infoWindow &&
+ position == typedOther.position &&
+ rotation == typedOther.rotation &&
+ visible == typedOther.visible &&
+ zIndex == typedOther.zIndex &&
+ onTap == typedOther.onTap;
}
@override
diff --git a/packages/google_maps_flutter/lib/src/marker_updates.dart b/packages/google_maps_flutter/lib/src/marker_updates.dart
index 6c73b5e6a12d..8bcca6ccb830 100644
--- a/packages/google_maps_flutter/lib/src/marker_updates.dart
+++ b/packages/google_maps_flutter/lib/src/marker_updates.dart
@@ -39,6 +39,10 @@ class _MarkerUpdates {
final Set _markersToChange = currentMarkerIds
.intersection(prevMarkerIds)
.map(idToCurrentMarker)
+ .where((Marker _current) {
+ final Marker _previous = previousMarkers[_current.markerId];
+ return _current != _previous;
+ })
.toSet();
markersToAdd = _markersToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polygon.dart b/packages/google_maps_flutter/lib/src/polygon.dart
index 7592cb78d393..2230ae81afaf 100644
--- a/packages/google_maps_flutter/lib/src/polygon.dart
+++ b/packages/google_maps_flutter/lib/src/polygon.dart
@@ -150,7 +150,16 @@ class Polygon {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final Polygon typedOther = other;
- return polygonId == typedOther.polygonId;
+ return polygonId == typedOther.polygonId &&
+ consumeTapEvents == typedOther.consumeTapEvents &&
+ fillColor == typedOther.fillColor &&
+ geodesic == typedOther.geodesic &&
+ listEquals(points, typedOther.points) &&
+ visible == typedOther.visible &&
+ strokeColor == typedOther.strokeColor &&
+ strokeWidth == typedOther.strokeWidth &&
+ zIndex == typedOther.zIndex &&
+ onTap == typedOther.onTap;
}
@override
diff --git a/packages/google_maps_flutter/lib/src/polygon_updates.dart b/packages/google_maps_flutter/lib/src/polygon_updates.dart
index c7a04f426074..42e04fc9f8e4 100644
--- a/packages/google_maps_flutter/lib/src/polygon_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polygon_updates.dart
@@ -39,6 +39,10 @@ class _PolygonUpdates {
final Set _polygonsToChange = currentPolygonIds
.intersection(prevPolygonIds)
.map(idToCurrentPolygon)
+ .where((Polygon _current) {
+ final Polygon _previous = previousPolygons[_current.polygonId];
+ return _current != _previous;
+ })
.toSet();
polygonsToAdd = _polygonsToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polyline.dart b/packages/google_maps_flutter/lib/src/polyline.dart
index 5e93669a596e..7454711dd6b1 100644
--- a/packages/google_maps_flutter/lib/src/polyline.dart
+++ b/packages/google_maps_flutter/lib/src/polyline.dart
@@ -192,7 +192,19 @@ class Polyline {
if (identical(this, other)) return true;
if (other.runtimeType != runtimeType) return false;
final Polyline typedOther = other;
- return polylineId == typedOther.polylineId;
+ return polylineId == typedOther.polylineId &&
+ consumeTapEvents == typedOther.consumeTapEvents &&
+ color == typedOther.color &&
+ geodesic == typedOther.geodesic &&
+ jointType == typedOther.jointType &&
+ listEquals(patterns, typedOther.patterns) &&
+ listEquals(points, typedOther.points) &&
+ startCap == typedOther.startCap &&
+ endCap == typedOther.endCap &&
+ visible == typedOther.visible &&
+ width == typedOther.width &&
+ zIndex == typedOther.zIndex &&
+ onTap == typedOther.onTap;
}
@override
diff --git a/packages/google_maps_flutter/lib/src/polyline_updates.dart b/packages/google_maps_flutter/lib/src/polyline_updates.dart
index 5d82597fd212..3a966162d5c6 100644
--- a/packages/google_maps_flutter/lib/src/polyline_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polyline_updates.dart
@@ -41,6 +41,10 @@ class _PolylineUpdates {
final Set _polylinesToChange = currentPolylineIds
.intersection(prevPolylineIds)
.map(idToCurrentPolyline)
+ .where((Polyline _current) {
+ final Polyline _previous = previousPolylines[_current.polylineId];
+ return _current != _previous;
+ })
.toSet();
polylinesToAdd = _polylinesToAdd;
diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml
index 7504c1dd41a6..a7920323f0cb 100644
--- a/packages/google_maps_flutter/pubspec.yaml
+++ b/packages/google_maps_flutter/pubspec.yaml
@@ -2,7 +2,7 @@ name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
author: Flutter Team
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
-version: 0.5.20+6
+version: 0.5.20+7
dependencies:
flutter:
From 7a95ce902dfc794987bc3ab4e6be1fa65e0268cc Mon Sep 17 00:00:00 2001
From: Pau Picas
Date: Wed, 31 Jul 2019 11:40:38 +0200
Subject: [PATCH 2/4] Fix format and some typos
---
packages/google_maps_flutter/CHANGELOG.md | 2 +-
.../google_maps_flutter/lib/src/circle_updates.dart | 10 ++++++----
.../google_maps_flutter/lib/src/marker_updates.dart | 10 ++++++----
.../google_maps_flutter/lib/src/polygon_updates.dart | 10 ++++++----
.../google_maps_flutter/lib/src/polyline_updates.dart | 10 ++++++----
5 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md
index 199064ec6502..c24eb6c9c75b 100644
--- a/packages/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/CHANGELOG.md
@@ -1,6 +1,6 @@
## 0.5.20+7
-* Don't recreate map elements if they didn't change since las widget build.
+* Don't recreate map elements if they didn't change since last widget build.
## 0.5.20+6
diff --git a/packages/google_maps_flutter/lib/src/circle_updates.dart b/packages/google_maps_flutter/lib/src/circle_updates.dart
index 416e30356754..356f5ab5248b 100644
--- a/packages/google_maps_flutter/lib/src/circle_updates.dart
+++ b/packages/google_maps_flutter/lib/src/circle_updates.dart
@@ -36,13 +36,15 @@ class _CircleUpdates {
.map(idToCurrentCircle)
.toSet();
+ bool currentNotEqualsPrevious(Circle _current) {
+ final Circle _previous = previousCircles[_current.circleId];
+ return _current != _previous;
+ }
+
final Set _circlesToChange = currentCircleIds
.intersection(prevCircleIds)
.map(idToCurrentCircle)
- .where((Circle _current) {
- final Circle _previous = previousCircles[_current.circleId];
- return _current != _previous;
- })
+ .where(currentNotEqualsPrevious)
.toSet();
circlesToAdd = _circlesToAdd;
diff --git a/packages/google_maps_flutter/lib/src/marker_updates.dart b/packages/google_maps_flutter/lib/src/marker_updates.dart
index 8bcca6ccb830..6a0a3e45a1d4 100644
--- a/packages/google_maps_flutter/lib/src/marker_updates.dart
+++ b/packages/google_maps_flutter/lib/src/marker_updates.dart
@@ -36,13 +36,15 @@ class _MarkerUpdates {
.map(idToCurrentMarker)
.toSet();
+ bool currentNotEqualsPrevious(Marker _current) {
+ final Marker _previous = previousMarkers[_current.markerId];
+ return _current != _previous;
+ }
+
final Set _markersToChange = currentMarkerIds
.intersection(prevMarkerIds)
.map(idToCurrentMarker)
- .where((Marker _current) {
- final Marker _previous = previousMarkers[_current.markerId];
- return _current != _previous;
- })
+ .where(currentNotEqualsPrevious)
.toSet();
markersToAdd = _markersToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polygon_updates.dart b/packages/google_maps_flutter/lib/src/polygon_updates.dart
index 42e04fc9f8e4..91eb513ffdad 100644
--- a/packages/google_maps_flutter/lib/src/polygon_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polygon_updates.dart
@@ -36,13 +36,15 @@ class _PolygonUpdates {
.map(idToCurrentPolygon)
.toSet();
+ bool currentNotEqualsPrevious(Polygon _current) {
+ final Polygon _previous = previousPolygons[_current.polygonId];
+ return _current != _previous;
+ }
+
final Set _polygonsToChange = currentPolygonIds
.intersection(prevPolygonIds)
.map(idToCurrentPolygon)
- .where((Polygon _current) {
- final Polygon _previous = previousPolygons[_current.polygonId];
- return _current != _previous;
- })
+ .where(currentNotEqualsPrevious)
.toSet();
polygonsToAdd = _polygonsToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polyline_updates.dart b/packages/google_maps_flutter/lib/src/polyline_updates.dart
index 3a966162d5c6..78acabdec089 100644
--- a/packages/google_maps_flutter/lib/src/polyline_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polyline_updates.dart
@@ -38,13 +38,15 @@ class _PolylineUpdates {
.map(idToCurrentPolyline)
.toSet();
+ bool currentNotEqualsPrevious(Polyline _current) {
+ final Polyline _previous = previousPolylines[_current.polylineId];
+ return _current != _previous;
+ }
+
final Set _polylinesToChange = currentPolylineIds
.intersection(prevPolylineIds)
.map(idToCurrentPolyline)
- .where((Polyline _current) {
- final Polyline _previous = previousPolylines[_current.polylineId];
- return _current != _previous;
- })
+ .where(currentNotEqualsPrevious)
.toSet();
polylinesToAdd = _polylinesToAdd;
From 3b5674b29b2736f978f716ad354a12882f9effa7 Mon Sep 17 00:00:00 2001
From: Pau Picas
Date: Wed, 31 Jul 2019 12:20:46 +0200
Subject: [PATCH 3/4] Fix tests
---
packages/google_maps_flutter/test/circle_updates_test.dart | 4 ++--
packages/google_maps_flutter/test/fake_maps_controllers.dart | 2 ++
packages/google_maps_flutter/test/marker_updates_test.dart | 4 ++--
packages/google_maps_flutter/test/polygon_updates_test.dart | 4 ++--
packages/google_maps_flutter/test/polyline_updates_test.dart | 4 ++--
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/packages/google_maps_flutter/test/circle_updates_test.dart b/packages/google_maps_flutter/test/circle_updates_test.dart
index 4a3f14134e34..63eb4b223edd 100644
--- a/packages/google_maps_flutter/test/circle_updates_test.dart
+++ b/packages/google_maps_flutter/test/circle_updates_test.dart
@@ -75,10 +75,10 @@ void main() {
final Circle addedCircle = platformGoogleMap.circlesToAdd.first;
expect(addedCircle, equals(c2));
+
expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.circlesToChange.length, 1);
- expect(platformGoogleMap.circlesToChange.first, equals(c1));
+ expect(platformGoogleMap.circlesToChange.isEmpty, true);
});
testWidgets("Removing a circle", (WidgetTester tester) async {
diff --git a/packages/google_maps_flutter/test/fake_maps_controllers.dart b/packages/google_maps_flutter/test/fake_maps_controllers.dart
index d892ea1a7794..0ae12c815ff3 100644
--- a/packages/google_maps_flutter/test/fake_maps_controllers.dart
+++ b/packages/google_maps_flutter/test/fake_maps_controllers.dart
@@ -133,6 +133,7 @@ class FakePlatformGoogleMap {
final Set result = Set();
for (Map markerData in markersData) {
final String markerId = markerData['markerId'];
+ final double alpha = markerData['alpha'];
final bool draggable = markerData['draggable'];
final bool visible = markerData['visible'];
@@ -151,6 +152,7 @@ class FakePlatformGoogleMap {
draggable: draggable,
visible: visible,
infoWindow: infoWindow,
+ alpha: alpha,
));
}
diff --git a/packages/google_maps_flutter/test/marker_updates_test.dart b/packages/google_maps_flutter/test/marker_updates_test.dart
index cb5731d72875..9f72c554faa8 100644
--- a/packages/google_maps_flutter/test/marker_updates_test.dart
+++ b/packages/google_maps_flutter/test/marker_updates_test.dart
@@ -75,10 +75,10 @@ void main() {
final Marker addedMarker = platformGoogleMap.markersToAdd.first;
expect(addedMarker, equals(m2));
+
expect(platformGoogleMap.markerIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.markersToChange.length, 1);
- expect(platformGoogleMap.markersToChange.first, equals(m1));
+ expect(platformGoogleMap.markersToChange.isEmpty, true);
});
testWidgets("Removing a marker", (WidgetTester tester) async {
diff --git a/packages/google_maps_flutter/test/polygon_updates_test.dart b/packages/google_maps_flutter/test/polygon_updates_test.dart
index 77f096b70484..ed7abd49c3f3 100644
--- a/packages/google_maps_flutter/test/polygon_updates_test.dart
+++ b/packages/google_maps_flutter/test/polygon_updates_test.dart
@@ -75,10 +75,10 @@ void main() {
final Polygon addedPolygon = platformGoogleMap.polygonsToAdd.first;
expect(addedPolygon, equals(p2));
+
expect(platformGoogleMap.polygonIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.polygonsToChange.length, 1);
- expect(platformGoogleMap.polygonsToChange.first, equals(p1));
+ expect(platformGoogleMap.polygonsToChange.isEmpty, true);
});
testWidgets("Removing a polygon", (WidgetTester tester) async {
diff --git a/packages/google_maps_flutter/test/polyline_updates_test.dart b/packages/google_maps_flutter/test/polyline_updates_test.dart
index 6946df4c05ee..c36a07e7d082 100644
--- a/packages/google_maps_flutter/test/polyline_updates_test.dart
+++ b/packages/google_maps_flutter/test/polyline_updates_test.dart
@@ -75,10 +75,10 @@ void main() {
final Polyline addedPolyline = platformGoogleMap.polylinesToAdd.first;
expect(addedPolyline, equals(p2));
+
expect(platformGoogleMap.polylineIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.polylinesToChange.length, 1);
- expect(platformGoogleMap.polylinesToChange.first, equals(p1));
+ expect(platformGoogleMap.polylinesToChange.isEmpty, true);
});
testWidgets("Removing a polyline", (WidgetTester tester) async {
From 0105ecb87fd09da2e1e8753ad2a718c7b6518f51 Mon Sep 17 00:00:00 2001
From: Pau Picas
Date: Wed, 28 Aug 2019 16:34:17 +0200
Subject: [PATCH 4/4] Refactor some code and add tests
---
packages/google_maps_flutter/CHANGELOG.md | 2 +-
.../lib/src/circle_updates.dart | 10 +++--
.../lib/src/marker_updates.dart | 10 +++--
.../lib/src/polygon_updates.dart | 10 +++--
.../lib/src/polyline_updates.dart | 10 +++--
packages/google_maps_flutter/pubspec.yaml | 2 +-
.../test/circle_updates_test.dart | 43 ++++++++-----------
.../test/marker_updates_test.dart | 43 ++++++++-----------
.../test/polygon_updates_test.dart | 43 ++++++++-----------
.../test/polyline_updates_test.dart | 43 ++++++++-----------
10 files changed, 98 insertions(+), 118 deletions(-)
diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md
index c24eb6c9c75b..c88a00be904a 100644
--- a/packages/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/CHANGELOG.md
@@ -1,4 +1,4 @@
-## 0.5.20+7
+## 0.5.21
* Don't recreate map elements if they didn't change since last widget build.
diff --git a/packages/google_maps_flutter/lib/src/circle_updates.dart b/packages/google_maps_flutter/lib/src/circle_updates.dart
index 356f5ab5248b..c977c4182c98 100644
--- a/packages/google_maps_flutter/lib/src/circle_updates.dart
+++ b/packages/google_maps_flutter/lib/src/circle_updates.dart
@@ -36,15 +36,17 @@ class _CircleUpdates {
.map(idToCurrentCircle)
.toSet();
- bool currentNotEqualsPrevious(Circle _current) {
- final Circle _previous = previousCircles[_current.circleId];
- return _current != _previous;
+ /// Returns `true` if [current] is not equals to previous one with the
+ /// same id.
+ bool hasChanged(Circle current) {
+ final Circle previous = previousCircles[current.circleId];
+ return current != previous;
}
final Set _circlesToChange = currentCircleIds
.intersection(prevCircleIds)
.map(idToCurrentCircle)
- .where(currentNotEqualsPrevious)
+ .where(hasChanged)
.toSet();
circlesToAdd = _circlesToAdd;
diff --git a/packages/google_maps_flutter/lib/src/marker_updates.dart b/packages/google_maps_flutter/lib/src/marker_updates.dart
index 6a0a3e45a1d4..d4a08255e069 100644
--- a/packages/google_maps_flutter/lib/src/marker_updates.dart
+++ b/packages/google_maps_flutter/lib/src/marker_updates.dart
@@ -36,15 +36,17 @@ class _MarkerUpdates {
.map(idToCurrentMarker)
.toSet();
- bool currentNotEqualsPrevious(Marker _current) {
- final Marker _previous = previousMarkers[_current.markerId];
- return _current != _previous;
+ /// Returns `true` if [current] is not equals to previous one with the
+ /// same id.
+ bool hasChanged(Marker current) {
+ final Marker previous = previousMarkers[current.markerId];
+ return current != previous;
}
final Set _markersToChange = currentMarkerIds
.intersection(prevMarkerIds)
.map(idToCurrentMarker)
- .where(currentNotEqualsPrevious)
+ .where(hasChanged)
.toSet();
markersToAdd = _markersToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polygon_updates.dart b/packages/google_maps_flutter/lib/src/polygon_updates.dart
index 91eb513ffdad..5a14c6b8ec5c 100644
--- a/packages/google_maps_flutter/lib/src/polygon_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polygon_updates.dart
@@ -36,15 +36,17 @@ class _PolygonUpdates {
.map(idToCurrentPolygon)
.toSet();
- bool currentNotEqualsPrevious(Polygon _current) {
- final Polygon _previous = previousPolygons[_current.polygonId];
- return _current != _previous;
+ /// Returns `true` if [current] is not equals to previous one with the
+ /// same id.
+ bool hasChanged(Polygon current) {
+ final Polygon previous = previousPolygons[current.polygonId];
+ return current != previous;
}
final Set _polygonsToChange = currentPolygonIds
.intersection(prevPolygonIds)
.map(idToCurrentPolygon)
- .where(currentNotEqualsPrevious)
+ .where(hasChanged)
.toSet();
polygonsToAdd = _polygonsToAdd;
diff --git a/packages/google_maps_flutter/lib/src/polyline_updates.dart b/packages/google_maps_flutter/lib/src/polyline_updates.dart
index 78acabdec089..ed972a51c8bf 100644
--- a/packages/google_maps_flutter/lib/src/polyline_updates.dart
+++ b/packages/google_maps_flutter/lib/src/polyline_updates.dart
@@ -38,15 +38,17 @@ class _PolylineUpdates {
.map(idToCurrentPolyline)
.toSet();
- bool currentNotEqualsPrevious(Polyline _current) {
- final Polyline _previous = previousPolylines[_current.polylineId];
- return _current != _previous;
+ /// Returns `true` if [current] is not equals to previous one with the
+ /// same id.
+ bool hasChanged(Polyline current) {
+ final Polyline previous = previousPolylines[current.polylineId];
+ return current != previous;
}
final Set _polylinesToChange = currentPolylineIds
.intersection(prevPolylineIds)
.map(idToCurrentPolyline)
- .where(currentNotEqualsPrevious)
+ .where(hasChanged)
.toSet();
polylinesToAdd = _polylinesToAdd;
diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml
index a7920323f0cb..f8a852998d42 100644
--- a/packages/google_maps_flutter/pubspec.yaml
+++ b/packages/google_maps_flutter/pubspec.yaml
@@ -2,7 +2,7 @@ name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
author: Flutter Team
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
-version: 0.5.20+7
+version: 0.5.21
dependencies:
flutter:
diff --git a/packages/google_maps_flutter/test/circle_updates_test.dart b/packages/google_maps_flutter/test/circle_updates_test.dart
index 63eb4b223edd..001b4d58a0f1 100644
--- a/packages/google_maps_flutter/test/circle_updates_test.dart
+++ b/packages/google_maps_flutter/test/circle_updates_test.dart
@@ -172,29 +172,22 @@ void main() {
expect(platformGoogleMap.circleIdsToRemove.first, equals(c3.circleId));
});
- testWidgets(
- "Partial Update",
- (WidgetTester tester) async {
- final Circle c1 = Circle(circleId: CircleId("circle_1"));
- Circle c2 = Circle(circleId: CircleId("circle_2"));
- final Set prev = _toSet(c1: c1, c2: c2);
- c2 = Circle(circleId: CircleId("circle_2"), radius: 10);
- final Set cur = _toSet(c1: c1, c2: c2);
-
- await tester.pumpWidget(_mapWithCircles(prev));
- await tester.pumpWidget(_mapWithCircles(cur));
-
- final FakePlatformGoogleMap platformGoogleMap =
- fakePlatformViewsController.lastCreatedView;
-
- expect(platformGoogleMap.circlesToChange, _toSet(c2: c2));
- expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.circlesToAdd.isEmpty, true);
- },
- // The test is currently broken due to a bug (we're updating all circles
- // instead of just the ones that were changed):
- // https://github.com/flutter/flutter/issues/30764
- // TODO(amirh): enable this test when the issue is fixed.
- skip: true,
- );
+ testWidgets("Partial Update", (WidgetTester tester) async {
+ final Circle c1 = Circle(circleId: CircleId("circle_1"));
+ final Circle c2 = Circle(circleId: CircleId("circle_2"));
+ Circle c3 = Circle(circleId: CircleId("circle_3"));
+ final Set prev = _toSet(c1: c1, c2: c2, c3: c3);
+ c3 = Circle(circleId: CircleId("circle_3"), radius: 10);
+ final Set cur = _toSet(c1: c1, c2: c2, c3: c3);
+
+ await tester.pumpWidget(_mapWithCircles(prev));
+ await tester.pumpWidget(_mapWithCircles(cur));
+
+ final FakePlatformGoogleMap platformGoogleMap =
+ fakePlatformViewsController.lastCreatedView;
+
+ expect(platformGoogleMap.circlesToChange, _toSet(c3: c3));
+ expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
+ expect(platformGoogleMap.circlesToAdd.isEmpty, true);
+ });
}
diff --git a/packages/google_maps_flutter/test/marker_updates_test.dart b/packages/google_maps_flutter/test/marker_updates_test.dart
index 9f72c554faa8..e208e82e2a96 100644
--- a/packages/google_maps_flutter/test/marker_updates_test.dart
+++ b/packages/google_maps_flutter/test/marker_updates_test.dart
@@ -175,29 +175,22 @@ void main() {
expect(platformGoogleMap.markerIdsToRemove.first, equals(m3.markerId));
});
- testWidgets(
- "Partial Update",
- (WidgetTester tester) async {
- final Marker m1 = Marker(markerId: MarkerId("marker_1"));
- Marker m2 = Marker(markerId: MarkerId("marker_2"));
- final Set prev = _toSet(m1: m1, m2: m2);
- m2 = Marker(markerId: MarkerId("marker_2"), draggable: true);
- final Set cur = _toSet(m1: m1, m2: m2);
-
- await tester.pumpWidget(_mapWithMarkers(prev));
- await tester.pumpWidget(_mapWithMarkers(cur));
-
- final FakePlatformGoogleMap platformGoogleMap =
- fakePlatformViewsController.lastCreatedView;
-
- expect(platformGoogleMap.markersToChange, _toSet(m2: m2));
- expect(platformGoogleMap.markerIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.markersToAdd.isEmpty, true);
- },
- // The test is currently broken due to a bug (we're updating all markers
- // instead of just the ones that were changed):
- // https://github.com/flutter/flutter/issues/27823
- // TODO(amirh): enable this test when the issue is fixed.
- skip: true,
- );
+ testWidgets("Partial Update", (WidgetTester tester) async {
+ final Marker m1 = Marker(markerId: MarkerId("marker_1"));
+ final Marker m2 = Marker(markerId: MarkerId("marker_2"));
+ Marker m3 = Marker(markerId: MarkerId("marker_3"));
+ final Set prev = _toSet(m1: m1, m2: m2, m3: m3);
+ m3 = Marker(markerId: MarkerId("marker_3"), draggable: true);
+ final Set cur = _toSet(m1: m1, m2: m2, m3: m3);
+
+ await tester.pumpWidget(_mapWithMarkers(prev));
+ await tester.pumpWidget(_mapWithMarkers(cur));
+
+ final FakePlatformGoogleMap platformGoogleMap =
+ fakePlatformViewsController.lastCreatedView;
+
+ expect(platformGoogleMap.markersToChange, _toSet(m3: m3));
+ expect(platformGoogleMap.markerIdsToRemove.isEmpty, true);
+ expect(platformGoogleMap.markersToAdd.isEmpty, true);
+ });
}
diff --git a/packages/google_maps_flutter/test/polygon_updates_test.dart b/packages/google_maps_flutter/test/polygon_updates_test.dart
index ed7abd49c3f3..c666cb687fee 100644
--- a/packages/google_maps_flutter/test/polygon_updates_test.dart
+++ b/packages/google_maps_flutter/test/polygon_updates_test.dart
@@ -174,29 +174,22 @@ void main() {
expect(platformGoogleMap.polygonIdsToRemove.first, equals(p3.polygonId));
});
- testWidgets(
- "Partial Update",
- (WidgetTester tester) async {
- final Polygon p1 = Polygon(polygonId: PolygonId("polygon_1"));
- Polygon p2 = Polygon(polygonId: PolygonId("polygon_2"));
- final Set prev = _toSet(p1: p1, p2: p2);
- p2 = Polygon(polygonId: PolygonId("polygon_2"), geodesic: true);
- final Set cur = _toSet(p1: p1, p2: p2);
-
- await tester.pumpWidget(_mapWithPolygons(prev));
- await tester.pumpWidget(_mapWithPolygons(cur));
-
- final FakePlatformGoogleMap platformGoogleMap =
- fakePlatformViewsController.lastCreatedView;
-
- expect(platformGoogleMap.polygonsToChange, _toSet(p2: p2));
- expect(platformGoogleMap.polygonIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.polygonsToAdd.isEmpty, true);
- },
- // The test is currently broken due to a bug (we're updating all polygons
- // instead of just the ones that were changed):
- // https://github.com/flutter/flutter/issues/30764
- // TODO(amirh): enable this test when the issue is fixed.
- skip: true,
- );
+ testWidgets("Partial Update", (WidgetTester tester) async {
+ final Polygon p1 = Polygon(polygonId: PolygonId("polygon_1"));
+ final Polygon p2 = Polygon(polygonId: PolygonId("polygon_2"));
+ Polygon p3 = Polygon(polygonId: PolygonId("polygon_3"));
+ final Set prev = _toSet(p1: p1, p2: p2, p3: p3);
+ p3 = Polygon(polygonId: PolygonId("polygon_3"), geodesic: true);
+ final Set cur = _toSet(p1: p1, p2: p2, p3: p3);
+
+ await tester.pumpWidget(_mapWithPolygons(prev));
+ await tester.pumpWidget(_mapWithPolygons(cur));
+
+ final FakePlatformGoogleMap platformGoogleMap =
+ fakePlatformViewsController.lastCreatedView;
+
+ expect(platformGoogleMap.polygonsToChange, _toSet(p3: p3));
+ expect(platformGoogleMap.polygonIdsToRemove.isEmpty, true);
+ expect(platformGoogleMap.polygonsToAdd.isEmpty, true);
+ });
}
diff --git a/packages/google_maps_flutter/test/polyline_updates_test.dart b/packages/google_maps_flutter/test/polyline_updates_test.dart
index c36a07e7d082..a0f39185d472 100644
--- a/packages/google_maps_flutter/test/polyline_updates_test.dart
+++ b/packages/google_maps_flutter/test/polyline_updates_test.dart
@@ -174,29 +174,22 @@ void main() {
expect(platformGoogleMap.polylineIdsToRemove.first, equals(p3.polylineId));
});
- testWidgets(
- "Partial Update",
- (WidgetTester tester) async {
- final Polyline p1 = Polyline(polylineId: PolylineId("polyline_1"));
- Polyline p2 = Polyline(polylineId: PolylineId("polyline_2"));
- final Set prev = _toSet(p1: p1, p2: p2);
- p2 = Polyline(polylineId: PolylineId("polyline_2"), geodesic: true);
- final Set cur = _toSet(p1: p1, p2: p2);
-
- await tester.pumpWidget(_mapWithPolylines(prev));
- await tester.pumpWidget(_mapWithPolylines(cur));
-
- final FakePlatformGoogleMap platformGoogleMap =
- fakePlatformViewsController.lastCreatedView;
-
- expect(platformGoogleMap.polylinesToChange, _toSet(p2: p2));
- expect(platformGoogleMap.polylineIdsToRemove.isEmpty, true);
- expect(platformGoogleMap.polylinesToAdd.isEmpty, true);
- },
- // The test is currently broken due to a bug (we're updating all polylines
- // instead of just the ones that were changed):
- // https://github.com/flutter/flutter/issues/30764
- // TODO(amirh): enable this test when the issue is fixed.
- skip: true,
- );
+ testWidgets("Partial Update", (WidgetTester tester) async {
+ final Polyline p1 = Polyline(polylineId: PolylineId("polyline_1"));
+ final Polyline p2 = Polyline(polylineId: PolylineId("polyline_2"));
+ Polyline p3 = Polyline(polylineId: PolylineId("polyline_3"));
+ final Set prev = _toSet(p1: p1, p2: p2, p3: p3);
+ p3 = Polyline(polylineId: PolylineId("polyline_3"), geodesic: true);
+ final Set cur = _toSet(p1: p1, p2: p2, p3: p3);
+
+ await tester.pumpWidget(_mapWithPolylines(prev));
+ await tester.pumpWidget(_mapWithPolylines(cur));
+
+ final FakePlatformGoogleMap platformGoogleMap =
+ fakePlatformViewsController.lastCreatedView;
+
+ expect(platformGoogleMap.polylinesToChange, _toSet(p3: p3));
+ expect(platformGoogleMap.polylineIdsToRemove.isEmpty, true);
+ expect(platformGoogleMap.polylinesToAdd.isEmpty, true);
+ });
}