From 5cf5bf95f4ff8201c946ea30f6293b12b049049a Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 15:22:48 -0400 Subject: [PATCH 01/10] Convert JointType to enum --- .../flutter/plugins/googlemaps/Convert.java | 2 +- .../flutter/plugins/googlemaps/Messages.java | 49 +++++++++++++++---- .../lib/src/google_maps_flutter_android.dart | 14 +++++- .../lib/src/messages.g.dart | 19 ++++++- .../pigeons/messages.dart | 8 ++- 5 files changed, 78 insertions(+), 14 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index cc4297ceb06c..30965b7c23af 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -713,7 +713,7 @@ static String interpretPolylineOptions( sink.setEndCap(toCap(polyline.getEndCap(), assetManager, density)); sink.setStartCap(toCap(polyline.getStartCap(), assetManager, density)); sink.setGeodesic(polyline.getGeodesic()); - sink.setJointType(polyline.getJointType().intValue()); + sink.setJointType(polyline.getJointType().index); sink.setVisible(polyline.getVisible()); sink.setWidth(polyline.getWidth()); sink.setZIndex(polyline.getZIndex()); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java index 26720bf1ddc7..3fcc74f3c690 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java @@ -100,6 +100,18 @@ private PlatformRendererType(final int index) { } } + public enum PlatformJointType { + MITERED(0), + BEVEL(1), + ROUND(2); + + final int index; + + private PlatformJointType(final int index) { + this.index = index; + } + } + /** * Pigeon representatation of a CameraPosition. * @@ -1760,19 +1772,29 @@ public void setGeodesic(@NonNull Boolean setterArg) { this.geodesic = setterArg; } - private @NonNull Long jointType; + /** + * The joint type as an integer. This must be a value corresponding to one of the values defined + * in the platform interface package's JointType enum. The integer values specified in this enum + * must match those used by the native SDK. + */ + private @NonNull PlatformJointType jointType; - public @NonNull Long getJointType() { + public @NonNull PlatformJointType getJointType() { return jointType; } - public void setJointType(@NonNull Long setterArg) { + public void setJointType(@NonNull PlatformJointType setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"jointType\" is null."); } this.jointType = setterArg; } + /** + * The pattern data, as JSON. Each element in this list should be set only from + * PatternItem.toJson, and the native code must interpret it according to the internal + * implementation details of that method. + */ private @NonNull List patterns; public @NonNull List getPatterns() { @@ -1799,6 +1821,10 @@ public void setPoints(@NonNull List setterArg) { this.points = setterArg; } + /** + * The start and end cap data, as JSON. These should be set only from Cap.toJson, and the native + * code must interpret it according to the internal implementation details of that method. + */ private @NonNull Object startCap; public @NonNull Object getStartCap() { @@ -1941,10 +1967,10 @@ public static final class Builder { return this; } - private @Nullable Long jointType; + private @Nullable PlatformJointType jointType; @CanIgnoreReturnValue - public @NonNull Builder setJointType(@NonNull Long setterArg) { + public @NonNull Builder setJointType(@NonNull PlatformJointType setterArg) { this.jointType = setterArg; return this; } @@ -2053,10 +2079,7 @@ ArrayList toList() { Object geodesic = __pigeon_list.get(3); pigeonResult.setGeodesic((Boolean) geodesic); Object jointType = __pigeon_list.get(4); - pigeonResult.setJointType( - (jointType == null) - ? null - : ((jointType instanceof Integer) ? (Integer) jointType : (Long) jointType)); + pigeonResult.setJointType((PlatformJointType) jointType); Object patterns = __pigeon_list.get(5); pigeonResult.setPatterns((List) patterns); Object points = __pigeon_list.get(6); @@ -4177,6 +4200,11 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { Object value = readValue(buffer); return value == null ? null : PlatformRendererType.values()[(int) value]; } + case (byte) 153: + { + Object value = readValue(buffer); + return value == null ? null : PlatformJointType.values()[(int) value]; + } default: return super.readValueOfType(type, buffer); } @@ -4256,6 +4284,9 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof PlatformRendererType) { stream.write(152); writeValue(stream, value == null ? null : ((PlatformRendererType) value).index); + } else if (value instanceof PlatformJointType) { + stream.write(153); + writeValue(stream, value == null ? null : ((PlatformJointType) value).index); } else { super.writeValue(stream, value); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 7b4fa3811260..3a463ec6393d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -766,6 +766,18 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { ); } + static PlatformJointType _platformJointTypeFromJointType( + JointType jointType) { + switch (jointType) { + case JointType.mitered: + return PlatformJointType.mitered; + case JointType.bevel: + return PlatformJointType.bevel; + case JointType.round: + return PlatformJointType.round; + } + } + static PlatformPolyline _platformPolylineFromPolyline(Polyline polyline) { final List points = polyline.points.map(_platformLatLngFromLatLng).toList(); @@ -783,7 +795,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { width: polyline.width, zIndex: polyline.zIndex, points: points, - jointType: polyline.jointType.value, + jointType: _platformJointTypeFromJointType(polyline.jointType), patterns: pattern, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart index d96319107c7a..fae122579b70 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart @@ -43,6 +43,12 @@ enum PlatformRendererType { latest, } +enum PlatformJointType { + mitered, + bevel, + round, +} + /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { PlatformCameraPosition({ @@ -448,12 +454,15 @@ class PlatformPolyline { bool geodesic; - int jointType; + /// The joint type as an integer. This must be a value corresponding to one of the values defined in the platform interface package's JointType enum. The integer values specified in this enum must match those used by the native SDK. + PlatformJointType jointType; + /// The pattern data, as JSON. Each element in this list should be set only from PatternItem.toJson, and the native code must interpret it according to the internal implementation details of that method. List patterns; List points; + /// The start and end cap data, as JSON. These should be set only from Cap.toJson, and the native code must interpret it according to the internal implementation details of that method. Object startCap; Object endCap; @@ -488,7 +497,7 @@ class PlatformPolyline { consumesTapEvents: result[1]! as bool, color: result[2]! as int, geodesic: result[3]! as bool, - jointType: result[4]! as int, + jointType: result[4]! as PlatformJointType, patterns: (result[5] as List?)!.cast(), points: (result[6] as List?)!.cast(), startCap: result[7]!, @@ -1081,6 +1090,9 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformRendererType) { buffer.putUint8(152); writeValue(buffer, value.index); + } else if (value is PlatformJointType) { + buffer.putUint8(153); + writeValue(buffer, value.index); } else { super.writeValue(buffer, value); } @@ -1139,6 +1151,9 @@ class _PigeonCodec extends StandardMessageCodec { case 152: final int? value = readValue(buffer) as int?; return value == null ? null : PlatformRendererType.values[value]; + case 153: + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformJointType.values[value]; default: return super.readValueOfType(type, buffer); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index 6f97587c9002..f64514432094 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -181,6 +181,12 @@ class PlatformPolygon { final int zIndex; } +enum PlatformJointType { + mitered, + bevel, + round, +} + /// Pigeon equivalent of the Polyline class. class PlatformPolyline { PlatformPolyline({ @@ -206,7 +212,7 @@ class PlatformPolyline { /// The joint type as an integer. This must be a value corresponding to one of the values defined in the platform interface package's JointType enum. The integer values specified in this enum must match those used by the native SDK. // TODO(schectman): Convert field to enum. // https://github.com/flutter/flutter/issues/153718 - final int jointType; + final PlatformJointType jointType; /// The pattern data, as JSON. Each element in this list should be set only from PatternItem.toJson, and the native code must interpret it according to the internal implementation details of that method. // TODO(schectman): Convert field to structured data. From 564e5b86d83b55e5c0b3eb6613ff9d752486ef59 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 15:24:08 -0400 Subject: [PATCH 02/10] Comment enum --- .../google_maps_flutter_android/pigeons/messages.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index f64514432094..20f8365b9e9c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -181,6 +181,7 @@ class PlatformPolygon { final int zIndex; } +/// Join types for polyline joints. The indices of this enum must match those used internally by the maps SDK. enum PlatformJointType { mitered, bevel, @@ -209,9 +210,7 @@ class PlatformPolyline { final int color; final bool geodesic; - /// The joint type as an integer. This must be a value corresponding to one of the values defined in the platform interface package's JointType enum. The integer values specified in this enum must match those used by the native SDK. - // TODO(schectman): Convert field to enum. - // https://github.com/flutter/flutter/issues/153718 + /// The joint type. The integer indices of this enum must match those used by the native SDK. final PlatformJointType jointType; /// The pattern data, as JSON. Each element in this list should be set only from PatternItem.toJson, and the native code must interpret it according to the internal implementation details of that method. From df0084eb5fa33abe6495436fb4ea69d36e2e4ea0 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 15:26:05 -0400 Subject: [PATCH 03/10] changelog --- .../google_maps_flutter_android/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index 05213232e0e3..e90ed745ab1e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Converts `JointType` to enum. + ## 2.14.4 * Converts 'PlatformTileOverlay' to pigeon. From 5c4f98957da188922af659e41ce76ea97e13c7ba Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 15:37:24 -0400 Subject: [PATCH 04/10] Update unit test --- .../lib/src/google_maps_flutter_android.dart | 26 +++++++++---------- .../google_maps_flutter_android_test.dart | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 3a463ec6393d..7cbdce6cd976 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -766,18 +766,6 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { ); } - static PlatformJointType _platformJointTypeFromJointType( - JointType jointType) { - switch (jointType) { - case JointType.mitered: - return PlatformJointType.mitered; - case JointType.bevel: - return PlatformJointType.bevel; - case JointType.round: - return PlatformJointType.round; - } - } - static PlatformPolyline _platformPolylineFromPolyline(Polyline polyline) { final List points = polyline.points.map(_platformLatLngFromLatLng).toList(); @@ -795,7 +783,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { width: polyline.width, zIndex: polyline.zIndex, points: points, - jointType: _platformJointTypeFromJointType(polyline.jointType), + jointType: platformJointTypeFromJointType(polyline.jointType), patterns: pattern, ); } @@ -1158,6 +1146,18 @@ PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( return PlatformZoomRange(min: minMaxZoom[0], max: minMaxZoom[1]); } +PlatformJointType platformJointTypeFromJointType( + JointType jointType) { + switch (jointType) { + case JointType.mitered: + return PlatformJointType.mitered; + case JointType.bevel: + return PlatformJointType.bevel; + case JointType.round: + return PlatformJointType.round; + } +} + /// Update specification for a set of [TileOverlay]s. // TODO(stuartmorgan): Fix the missing export of this class in the platform // interface, and remove this copy. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart index a3406690d5f3..293899ac7c67 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart @@ -546,7 +546,7 @@ void main() { expected.consumeTapEvents, expected.color.value, expected.geodesic, - expected.jointType.value, + platformJointTypeFromJointType(expected.jointType), ]); expect(encoded.sublist(9), [ expected.visible, From 0e8c5da679c8c812ee6af457a7768a6e828e6308 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 15:44:08 -0400 Subject: [PATCH 05/10] Doc comment --- .../lib/src/google_maps_flutter_android.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 7cbdce6cd976..41c8c1345dbd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -1146,6 +1146,8 @@ PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( return PlatformZoomRange(min: minMaxZoom[0], max: minMaxZoom[1]); } +/// Converts platform interface's JointType to Pigeon's PlatformJointType. +@visibleForTesting PlatformJointType platformJointTypeFromJointType( JointType jointType) { switch (jointType) { From e39052b972c41d6e08949cfbfb557be9cd72250e Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Fri, 30 Aug 2024 17:54:16 -0400 Subject: [PATCH 06/10] PR feedback --- .../io/flutter/plugins/googlemaps/Convert.java | 15 ++++++++++++++- .../lib/src/google_maps_flutter_android.dart | 3 +-- .../pigeons/messages.dart | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 30965b7c23af..07ce1481400f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -703,6 +703,19 @@ static String interpretPolygonOptions(Messages.PlatformPolygon polygon, PolygonO return polygon.getPolygonId(); } + static int jointTypeFromPigeon(Messages.PlatformJointType jointType) { + switch (jointType) { + case MITERED: + return 0; + case BEVEL: + return 1; + case ROUND: + return 2; + } + // These integer values come from a different package. This fallback ensures some value is returned in case a new enum value is added. + return 0; + } + static String interpretPolylineOptions( Messages.PlatformPolyline polyline, PolylineOptionsSink sink, @@ -713,7 +726,7 @@ static String interpretPolylineOptions( sink.setEndCap(toCap(polyline.getEndCap(), assetManager, density)); sink.setStartCap(toCap(polyline.getStartCap(), assetManager, density)); sink.setGeodesic(polyline.getGeodesic()); - sink.setJointType(polyline.getJointType().index); + sink.setJointType(jointTypeFromPigeon(polyline.getJointType())); sink.setVisible(polyline.getVisible()); sink.setWidth(polyline.getWidth()); sink.setZIndex(polyline.getZIndex()); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 41c8c1345dbd..5d100758503d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -1148,8 +1148,7 @@ PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( /// Converts platform interface's JointType to Pigeon's PlatformJointType. @visibleForTesting -PlatformJointType platformJointTypeFromJointType( - JointType jointType) { +PlatformJointType platformJointTypeFromJointType(JointType jointType) { switch (jointType) { case JointType.mitered: return PlatformJointType.mitered; diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index 20f8365b9e9c..42b238987e34 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -181,7 +181,7 @@ class PlatformPolygon { final int zIndex; } -/// Join types for polyline joints. The indices of this enum must match those used internally by the maps SDK. +/// Join types for polyline joints. enum PlatformJointType { mitered, bevel, From 237c4259c6ff246531e469b79ae23fe13b3c1636 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Tue, 3 Sep 2024 07:39:57 -0400 Subject: [PATCH 07/10] PR feedback --- .../src/main/java/io/flutter/plugins/googlemaps/Convert.java | 1 - .../google_maps_flutter_android/pigeons/messages.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 07ce1481400f..cfcfdafb9b3b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -712,7 +712,6 @@ static int jointTypeFromPigeon(Messages.PlatformJointType jointType) { case ROUND: return 2; } - // These integer values come from a different package. This fallback ensures some value is returned in case a new enum value is added. return 0; } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index 42b238987e34..b303d46486b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -210,7 +210,7 @@ class PlatformPolyline { final int color; final bool geodesic; - /// The joint type. The integer indices of this enum must match those used by the native SDK. + /// The joint type. final PlatformJointType jointType; /// The pattern data, as JSON. Each element in this list should be set only from PatternItem.toJson, and the native code must interpret it according to the internal implementation details of that method. From e6e8121af80313e321070645ca61928885cf4eb1 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Tue, 3 Sep 2024 09:56:34 -0400 Subject: [PATCH 08/10] Fallback after switch --- .../lib/src/google_maps_flutter_android.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 5d100758503d..9f597baec20a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -1157,6 +1157,9 @@ PlatformJointType platformJointTypeFromJointType(JointType jointType) { case JointType.round: return PlatformJointType.round; } + // The JointType enum is defined in the platform interface package. A fallback return value here ensures the android package will not break if a new enum value is added. + // ignore: dead_code + return PlatformJointType.mitered; } /// Update specification for a set of [TileOverlay]s. From 5e2790399c83dc3b6555e3104eda83e580dad930 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Tue, 3 Sep 2024 14:05:27 -0400 Subject: [PATCH 09/10] Constants and comments --- .../main/java/io/flutter/plugins/googlemaps/Convert.java | 9 +++++---- .../lib/src/google_maps_flutter_android.dart | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index cfcfdafb9b3b..9c75e1d0d5e1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -29,6 +29,7 @@ import com.google.android.gms.maps.model.Dash; import com.google.android.gms.maps.model.Dot; import com.google.android.gms.maps.model.Gap; +import com.google.android.gms.maps.model.JointType; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.PatternItem; @@ -706,13 +707,13 @@ static String interpretPolygonOptions(Messages.PlatformPolygon polygon, PolygonO static int jointTypeFromPigeon(Messages.PlatformJointType jointType) { switch (jointType) { case MITERED: - return 0; + return JointType.DEFAULT; case BEVEL: - return 1; + return JointType.BEVEL; case ROUND: - return 2; + return JointType.ROUND; } - return 0; + return JointType.DEFAULT; } static String interpretPolylineOptions( diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 9f597baec20a..551a1a74314e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -1157,7 +1157,11 @@ PlatformJointType platformJointTypeFromJointType(JointType jointType) { case JointType.round: return PlatformJointType.round; } - // The JointType enum is defined in the platform interface package. A fallback return value here ensures the android package will not break if a new enum value is added. + // The enum comes from a different package, which could get a new value at + // any time, so provide a fallback that ensures this won't break when used + // with a version that contains new values. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. // ignore: dead_code return PlatformJointType.mitered; } From 70d7f1798f63644f0ba2bada4ec552dced5c6f45 Mon Sep 17 00:00:00 2001 From: Yaakov Schectman Date: Tue, 3 Sep 2024 14:24:09 -0400 Subject: [PATCH 10/10] Version bump --- .../google_maps_flutter_android/CHANGELOG.md | 2 +- .../google_maps_flutter_android/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index e90ed745ab1e..3225fee21a8b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,4 +1,4 @@ -## NEXT +## 2.14.5 * Converts `JointType` to enum. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml index 38c840c810de..64865310764c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.14.4 +version: 2.14.5 environment: sdk: ^3.4.0