From 47b8288dafc658264fd61546e0149da4d491b984 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:21:58 +0400 Subject: [PATCH 1/3] Copy platform interface package subdirectories --- .../CHANGELOG.md | 3 +- .../lib/src/types/marker.dart | 40 ++++++++++++++++--- .../pubspec.yaml | 4 +- .../test/types/marker_test.dart | 5 ++- 4 files changed, 42 insertions(+), 10 deletions(-) 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 d2e113d2f1a..711192521ac 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,5 +1,6 @@ -## NEXT +## 2.12.0 +* Deprecates `zIndex` parameter in Marker in favor of `zIndexInt`. * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. ## 2.11.1 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 0921d2d4ec5..01378aac32c 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 @@ -135,7 +135,7 @@ class Marker implements MapsObject { /// * is positioned at 0, 0; [position] is `LatLng(0.0, 0.0)` /// * has an axis-aligned icon; [rotation] is 0.0 /// * is visible; [visible] is true - /// * is placed at the base of the drawing order; [zIndex] is 0.0 + /// * is placed at the base of the drawing order; [zIndexInt] is 0 /// * reports [onTap] events /// * reports [onDragEnd] events const Marker({ @@ -150,13 +150,21 @@ class Marker implements MapsObject { this.position = const LatLng(0.0, 0.0), this.rotation = 0.0, this.visible = true, - this.zIndex = 0.0, + @Deprecated( + 'Use zIndexInt instead. ' + 'On some platforms zIndex is truncated to an int, which can lead to incorrect/unstable ordering.', + ) + double zIndex = 0.0, + int zIndexInt = 0, this.clusterManagerId, this.onTap, this.onDrag, this.onDragStart, this.onDragEnd, - }) : assert(0.0 <= alpha && alpha <= 1.0); + }) : assert(0.0 <= alpha && alpha <= 1.0), + assert(zIndex == 0.0 || zIndexInt == 0, + 'Only one of zIndex and zIndexInt can be provided'), + _zIndexNum = zIndexInt == 0 ? zIndex : zIndexInt; /// Uniquely identifies a [Marker]. final MarkerId markerId; @@ -214,12 +222,26 @@ class Marker implements MapsObject { /// True if the marker is visible. final bool visible; + final num _zIndexNum; + + /// The z-index of the marker, used to determine relative drawing order of + /// map overlays. + /// + /// Overlays are drawn in order of z-index, so that lower values means drawn + /// earlier, and thus appearing to be closer to the surface of the Earth. + // TODO(stuartmorgan): Make this an int when removing the deprecated double zIndex parameter. + @Deprecated( + 'Use zIndexInt instead. ' + 'On some platforms zIndex is truncated to an int, which can lead to incorrect/unstable ordering.', + ) + double get zIndex => _zIndexNum.toDouble(); + /// The z-index of the marker, used to determine relative drawing order of /// map overlays. /// /// Overlays are drawn in order of z-index, so that lower values means drawn /// earlier, and thus appearing to be closer to the surface of the Earth. - final double zIndex; + int get zIndexInt => _zIndexNum.round(); /// Callbacks to receive tap events for markers placed on this map. final VoidCallback? onTap; @@ -246,7 +268,12 @@ class Marker implements MapsObject { LatLng? positionParam, double? rotationParam, bool? visibleParam, + @Deprecated( + 'Use zIndexIntParam instead. ' + 'On some platforms zIndex is truncated to an int, which can lead to incorrect/unstable ordering.', + ) double? zIndexParam, + int? zIndexIntParam, VoidCallback? onTapParam, ValueChanged? onDragStartParam, ValueChanged? onDragParam, @@ -266,6 +293,7 @@ class Marker implements MapsObject { rotation: rotationParam ?? rotation, visible: visibleParam ?? visible, zIndex: zIndexParam ?? zIndex, + zIndexInt: zIndexIntParam ?? zIndexInt, onTap: onTapParam ?? onTap, onDragStart: onDragStartParam ?? onDragStart, onDrag: onDragParam ?? onDrag, @@ -301,6 +329,7 @@ class Marker implements MapsObject { addIfPresent('rotation', rotation); addIfPresent('visible', visible); addIfPresent('zIndex', zIndex); + addIfPresent('zIndexInt', zIndexInt); addIfPresent('clusterManagerId', clusterManagerId?.value); return json; } @@ -326,6 +355,7 @@ class Marker implements MapsObject { rotation == other.rotation && visible == other.visible && zIndex == other.zIndex && + zIndexInt == other.zIndexInt && clusterManagerId == other.clusterManagerId; } @@ -337,7 +367,7 @@ class Marker implements MapsObject { return 'Marker{markerId: $markerId, alpha: $alpha, anchor: $anchor, ' 'consumeTapEvents: $consumeTapEvents, draggable: $draggable, flat: $flat, ' 'icon: $icon, infoWindow: $infoWindow, position: $position, rotation: $rotation, ' - 'visible: $visible, zIndex: $zIndex, onTap: $onTap, onDragStart: $onDragStart, ' + 'visible: $visible, zIndex: $zIndex, zIndexInt:$zIndexInt onTap: $onTap, onDragStart: $onDragStart, ' 'onDrag: $onDrag, onDragEnd: $onDragEnd, clusterManagerId: $clusterManagerId}'; } } 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 27ce4594563..900d52653e6 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,11 +4,11 @@ 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.11.1 +version: 2.12.0 environment: sdk: ^3.6.0 - flutter: ">=3.27.0" + flutter: '>=3.27.0' dependencies: collection: ^1.15.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 76e5de2b186..c8d1327f467 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 @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter_test/flutter_test.dart'; - import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; void main() { @@ -24,6 +23,7 @@ void main() { expect(marker.rotation, equals(0.0)); expect(marker.visible, equals(true)); expect(marker.zIndex, equals(0.0)); + expect(marker.zIndexInt, equals(0)); expect(marker.onTap, equals(null)); expect(marker.onDrag, equals(null)); expect(marker.onDragStart, equals(null)); @@ -60,7 +60,7 @@ void main() { position: const LatLng(50, 50), rotation: 100, visible: false, - zIndex: 100, + zIndexInt: 100, onTap: () {}, onDragStart: (LatLng latLng) {}, onDrag: (LatLng latLng) {}, @@ -86,6 +86,7 @@ void main() { 'rotation': 100.0, 'visible': false, 'zIndex': 100.0, + 'zIndexInt': 100, }); }); test('clone', () { From 2960f23f88f5f1c4a785bb819357ae0d742c9eeb Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:29:42 +0400 Subject: [PATCH 2/3] Fix nits --- .../google_maps_flutter_platform_interface/CHANGELOG.md | 2 +- .../lib/src/types/marker.dart | 2 +- .../google_maps_flutter_platform_interface/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 711192521ac..44c04424e50 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.0 -* Deprecates `zIndex` parameter in Marker in favor of `zIndexInt`. +* Deprecates `zIndex` parameter in `Marker` in favor of `zIndexInt`. * Updates minimum supported SDK version to Flutter 3.27/Dart 3.6. ## 2.11.1 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 01378aac32c..fa64d2d977c 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 @@ -367,7 +367,7 @@ class Marker implements MapsObject { return 'Marker{markerId: $markerId, alpha: $alpha, anchor: $anchor, ' 'consumeTapEvents: $consumeTapEvents, draggable: $draggable, flat: $flat, ' 'icon: $icon, infoWindow: $infoWindow, position: $position, rotation: $rotation, ' - 'visible: $visible, zIndex: $zIndex, zIndexInt:$zIndexInt onTap: $onTap, onDragStart: $onDragStart, ' + 'visible: $visible, zIndex: $zIndex, onTap: $onTap, onDragStart: $onDragStart, ' 'onDrag: $onDrag, onDragEnd: $onDragEnd, clusterManagerId: $clusterManagerId}'; } } 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 900d52653e6..93df2f7f25e 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 @@ -8,7 +8,7 @@ version: 2.12.0 environment: sdk: ^3.6.0 - flutter: '>=3.27.0' + flutter: ">=3.27.0" dependencies: collection: ^1.15.0 From 48ba85afd46bd5a0056894ee4e00275be41706ac Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Wed, 4 Jun 2025 22:45:49 +0400 Subject: [PATCH 3/3] Tests for new params and assertt --- .../test/types/marker_test.dart | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) 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 c8d1327f467..35d16b4c7fa 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 @@ -170,5 +170,36 @@ void main() { copy.onDragEnd!(const LatLng(0, 1)); expect(log, contains('onDragEndParam')); }); + + test("Assert that both zIndex and zIndex int aren't passed in", () { + expect( + () => Marker( + markerId: const MarkerId('ABC123'), + zIndex: 5, + zIndexInt: 10, + ), + throwsAssertionError, + ); + }); + + test('zIndex param', () { + const Marker marker = Marker( + markerId: MarkerId('ABC123'), + zIndex: 5.00, + ); + + expect(marker.zIndexInt, 5); + expect(marker.zIndex, 5.00); + }); + + test('zIndexInt param', () { + const Marker marker = Marker( + markerId: MarkerId('ABC123'), + zIndexInt: 5, + ); + + expect(marker.zIndexInt, 5); + expect(marker.zIndex, 5.00); + }); }); }