diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index 44c04424e50..0ea36280b98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.12.1 + +* Fixes the `zIndex` issue in the `copyWith` method. + ## 2.12.0 * Deprecates `zIndex` parameter in `Marker` in favor of `zIndexInt`. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart index fa64d2d977c..d0c1f036c31 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart @@ -280,6 +280,8 @@ class Marker implements MapsObject { ValueChanged? onDragEndParam, ClusterManagerId? clusterManagerIdParam, }) { + assert(zIndexParam == null || zIndexIntParam == null, + 'Only one of zIndexParam and zIndexIntParam can be provided'); return Marker( markerId: markerId, alpha: alphaParam ?? alpha, @@ -292,8 +294,7 @@ class Marker implements MapsObject { position: positionParam ?? position, rotation: rotationParam ?? rotation, visible: visibleParam ?? visible, - zIndex: zIndexParam ?? zIndex, - zIndexInt: zIndexIntParam ?? zIndexInt, + zIndex: zIndexIntParam?.toDouble() ?? zIndexParam ?? zIndex, onTap: onTapParam ?? onTap, onDragStart: onDragStartParam ?? onDragStart, onDrag: onDragParam ?? onDrag, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 93df2f7f25e..3e8d1b950e8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 # 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.12.0 +version: 2.12.1 environment: sdk: ^3.6.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart index 35d16b4c7fa..ea366602999 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart @@ -201,5 +201,25 @@ void main() { expect(marker.zIndexInt, 5); expect(marker.zIndex, 5.00); }); + + test('zIndexInt param copyWith', () { + const Marker marker = Marker( + markerId: MarkerId('ABC123'), + zIndexInt: 5, + ); + final Marker copy = marker.copyWith(zIndexIntParam: 10); + expect(copy.zIndexInt, 10); + expect(copy.zIndex, 10.0); + }); + + test('zIndex param copyWith', () { + const Marker marker = Marker( + markerId: MarkerId('ABC123'), + zIndexInt: 5, + ); + final Marker copy = marker.copyWith(zIndexParam: 10.0); + expect(copy.zIndexInt, 10); + expect(copy.zIndex, 10.0); + }); }); }