From a322e0a648550c04c0411bbee0c7a204e6eefb8d Mon Sep 17 00:00:00 2001 From: yiiim Date: Fri, 6 Jun 2025 22:09:24 +0800 Subject: [PATCH 1/4] fix copyWith --- .../lib/src/types/marker.dart | 5 +++-- .../test/types/marker_test.dart | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) 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 fa64d2d977c5..c8464a4bfc07 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, + zIndexInt: zIndexIntParam ?? zIndexParam?.round() ?? zIndexInt, onTap: onTapParam ?? onTap, onDragStart: onDragStartParam ?? onDragStart, onDrag: onDragParam ?? onDrag, 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 35d16b4c7faa..ea3666029995 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); + }); }); } From 31198b797c563c7c892f5919d0f61aeffef3834b Mon Sep 17 00:00:00 2001 From: yiiim Date: Fri, 6 Jun 2025 22:10:11 +0800 Subject: [PATCH 2/4] fix copyWith --- .../google_maps_flutter_platform_interface/CHANGELOG.md | 4 ++++ .../google_maps_flutter_platform_interface/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 44c04424e504..e431e1333738 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 + +* Fix 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/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 93df2f7f25e7..3e8d1b950e86 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 From 3bca9178937caf29bc7a70f082b489321bf71ba8 Mon Sep 17 00:00:00 2001 From: yiiim Date: Fri, 6 Jun 2025 22:10:50 +0800 Subject: [PATCH 3/4] Fixes --- .../google_maps_flutter_platform_interface/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e431e1333738..0ea36280b98f 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,6 +1,6 @@ ## 2.12.1 -* Fix the `zIndex` issue in the `copyWith` method. +* Fixes the `zIndex` issue in the `copyWith` method. ## 2.12.0 From c1461b69fdcb1066bfc3d12e0313a228fde085ce Mon Sep 17 00:00:00 2001 From: yiiim Date: Fri, 6 Jun 2025 23:09:37 +0800 Subject: [PATCH 4/4] zIndex --- .../lib/src/types/marker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c8464a4bfc07..d0c1f036c31f 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 @@ -294,7 +294,7 @@ class Marker implements MapsObject { position: positionParam ?? position, rotation: rotationParam ?? rotation, visible: visibleParam ?? visible, - zIndexInt: zIndexIntParam ?? zIndexParam?.round() ?? zIndexInt, + zIndex: zIndexIntParam?.toDouble() ?? zIndexParam ?? zIndex, onTap: onTapParam ?? onTap, onDragStart: onDragStartParam ?? onDragStart, onDrag: onDragParam ?? onDrag,