[google_maps_flutter] Avoid unnecessary map element updates (performance) (#2235)

diff --git a/AUTHORS b/AUTHORS
index fe6fcee..b3957d2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -52,3 +52,4 @@
 Nissim Dsilva <nissim@tengio.com>
 Giancarlo Rocha <giancarloiff@gmail.com>
 Ryo Miyake <ryo@miyake.id>
+Théo Champion <contact.theochampion@gmail.com>
diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
index bf00be4..72e52cf 100644
--- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
+++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.25+2
+
+* Avoid unnecessary map elements updates by ignoring not platform related attributes (eg. onTap)
+
 ## 0.5.25+1
 
 * Add takeSnapshot that takes a snapshot of the map.
@@ -80,7 +84,7 @@
 
 ## 0.5.21+8
 
-* Add NS_ASSUME_NONNULL_* macro to reduce iOS compiler warnings.
+* Add NS*ASSUME_NONNULL*\* macro to reduce iOS compiler warnings.
 
 ## 0.5.21+7
 
@@ -153,12 +157,10 @@
 
 ## 0.5.19
 
-
 * Adds support for toggling Indoor View on or off.
 
 * Allow BitmapDescriptor scaling override
 
-
 ## 0.5.18
 
 * Fixed build issue on iOS.
@@ -339,4 +341,4 @@
 
 ## 0.0.2
 
-* Initial developers preview release.
+* Initial developers preview release.
\ No newline at end of file
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/circle.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/circle.dart
index 0de675d..3edfc88 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/src/circle.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/circle.dart
@@ -154,8 +154,7 @@
         strokeColor == typedOther.strokeColor &&
         strokeWidth == typedOther.strokeWidth &&
         visible == typedOther.visible &&
-        zIndex == typedOther.zIndex &&
-        onTap == typedOther.onTap;
+        zIndex == typedOther.zIndex;
   }
 
   @override
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/marker.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/marker.dart
index 5690cdd..480f0a3 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/src/marker.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/marker.dart
@@ -302,8 +302,7 @@
         position == typedOther.position &&
         rotation == typedOther.rotation &&
         visible == typedOther.visible &&
-        zIndex == typedOther.zIndex &&
-        onTap == typedOther.onTap;
+        zIndex == typedOther.zIndex;
   }
 
   @override
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/polygon.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/polygon.dart
index e6b26ca..973667e 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/src/polygon.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/polygon.dart
@@ -165,8 +165,7 @@
         visible == typedOther.visible &&
         strokeColor == typedOther.strokeColor &&
         strokeWidth == typedOther.strokeWidth &&
-        zIndex == typedOther.zIndex &&
-        onTap == typedOther.onTap;
+        zIndex == typedOther.zIndex;
   }
 
   @override
diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/polyline.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/polyline.dart
index 0d7684f..c27b19e 100644
--- a/packages/google_maps_flutter/google_maps_flutter/lib/src/polyline.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/polyline.dart
@@ -216,8 +216,7 @@
         endCap == typedOther.endCap &&
         visible == typedOther.visible &&
         width == typedOther.width &&
-        zIndex == typedOther.zIndex &&
-        onTap == typedOther.onTap;
+        zIndex == typedOther.zIndex;
   }
 
   @override
diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
index 45d63dd..ea38638 100644
--- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
+++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml
@@ -1,7 +1,7 @@
 name: google_maps_flutter
 description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
 homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter
-version: 0.5.25+1
+version: 0.5.25+2
 
 dependencies:
   flutter:
@@ -28,7 +28,6 @@
       ios:
         pluginClass: FLTGoogleMapsPlugin
 
-
 environment:
   sdk: ">=2.0.0-dev.47.0 <3.0.0"
   flutter: ">=1.12.13+hotfix.5 <2.0.0"
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
index 001b4d5..3533ceb 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart
@@ -190,4 +190,21 @@
     expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
     expect(platformGoogleMap.circlesToAdd.isEmpty, true);
   });
+
+  testWidgets("Update non platform related attr", (WidgetTester tester) async {
+    Circle c1 = Circle(circleId: CircleId("circle_1"));
+    final Set<Circle> prev = _toSet(c1: c1);
+    c1 = Circle(circleId: CircleId("circle_1"), onTap: () => print("hello"));
+    final Set<Circle> cur = _toSet(c1: c1);
+
+    await tester.pumpWidget(_mapWithCircles(prev));
+    await tester.pumpWidget(_mapWithCircles(cur));
+
+    final FakePlatformGoogleMap platformGoogleMap =
+        fakePlatformViewsController.lastCreatedView;
+
+    expect(platformGoogleMap.circlesToChange.isEmpty, true);
+    expect(platformGoogleMap.circleIdsToRemove.isEmpty, true);
+    expect(platformGoogleMap.circlesToAdd.isEmpty, true);
+  });
 }
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
index e208e82..620e1ef 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart
@@ -193,4 +193,24 @@
     expect(platformGoogleMap.markerIdsToRemove.isEmpty, true);
     expect(platformGoogleMap.markersToAdd.isEmpty, true);
   });
+
+  testWidgets("Update non platform related attr", (WidgetTester tester) async {
+    Marker m1 = Marker(markerId: MarkerId("marker_1"));
+    final Set<Marker> prev = _toSet(m1: m1);
+    m1 = Marker(
+        markerId: MarkerId("marker_1"),
+        onTap: () => print("hello"),
+        onDragEnd: (LatLng latLng) => print(latLng));
+    final Set<Marker> cur = _toSet(m1: m1);
+
+    await tester.pumpWidget(_mapWithMarkers(prev));
+    await tester.pumpWidget(_mapWithMarkers(cur));
+
+    final FakePlatformGoogleMap platformGoogleMap =
+        fakePlatformViewsController.lastCreatedView;
+
+    expect(platformGoogleMap.markersToChange.isEmpty, true);
+    expect(platformGoogleMap.markerIdsToRemove.isEmpty, true);
+    expect(platformGoogleMap.markersToAdd.isEmpty, true);
+  });
 }
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
index a884254..185c996 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart
@@ -211,4 +211,21 @@
     expect(platformGoogleMap.polygonIdsToRemove.isEmpty, true);
     expect(platformGoogleMap.polygonsToAdd.isEmpty, true);
   });
+
+  testWidgets("Update non platform related attr", (WidgetTester tester) async {
+    Polygon p1 = Polygon(polygonId: PolygonId("polygon_1"));
+    final Set<Polygon> prev = _toSet(p1: p1);
+    p1 = Polygon(polygonId: PolygonId("polygon_1"), onTap: () => print(2 + 2));
+    final Set<Polygon> cur = _toSet(p1: p1);
+
+    await tester.pumpWidget(_mapWithPolygons(prev));
+    await tester.pumpWidget(_mapWithPolygons(cur));
+
+    final FakePlatformGoogleMap platformGoogleMap =
+        fakePlatformViewsController.lastCreatedView;
+
+    expect(platformGoogleMap.polygonsToChange.isEmpty, true);
+    expect(platformGoogleMap.polygonIdsToRemove.isEmpty, true);
+    expect(platformGoogleMap.polygonsToAdd.isEmpty, true);
+  });
 }
diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
index ddc64bf..269e8f1 100644
--- a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart
@@ -211,4 +211,26 @@
     expect(platformGoogleMap.polylineIdsToRemove.isEmpty, true);
     expect(platformGoogleMap.polylinesToAdd.isEmpty, true);
   });
+
+  testWidgets("Update non platform related attr", (WidgetTester tester) async {
+    Polyline p1 = Polyline(polylineId: PolylineId("polyline_1"), onTap: null);
+    final Set<Polyline> prev = _toSet(
+      p1: p1,
+    );
+    p1 = Polyline(
+        polylineId: PolylineId("polyline_1"), onTap: () => print(2 + 2));
+    final Set<Polyline> cur = _toSet(
+      p1: p1,
+    );
+
+    await tester.pumpWidget(_mapWithPolylines(prev));
+    await tester.pumpWidget(_mapWithPolylines(cur));
+
+    final FakePlatformGoogleMap platformGoogleMap =
+        fakePlatformViewsController.lastCreatedView;
+
+    expect(platformGoogleMap.polylinesToChange.isEmpty, true);
+    expect(platformGoogleMap.polylineIdsToRemove.isEmpty, true);
+    expect(platformGoogleMap.polylinesToAdd.isEmpty, true);
+  });
 }