Skip to content

Commit 631e97a

Browse files
[google_maps_flutter] Replace deprecated color APIs in platform interface (#10477)
Replaces the deprecated `Color.value` with the replacement `toARGB()`. Since this is for legacy JSON representations, it continues it must remain compatible, so uses the same representation (unlike #10474 where it's replaced with structured representations). Part of flutter/flutter#159739 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 1cbe8d7 commit 631e97a

File tree

10 files changed

+28
-21
lines changed

10 files changed

+28
-21
lines changed

packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.14.1
22

3+
* Replaces internal use of deprecated methods.
34
* Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.
45

56
## 2.14.0

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/serialization.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ Object serializeHeatmapGradient(HeatmapGradient gradient) {
130130
_addIfNonNull(
131131
json,
132132
_heatmapGradientColorsKey,
133-
gradient.colors.map((HeatmapGradientColor e) => e.color.value).toList(),
133+
gradient.colors
134+
.map((HeatmapGradientColor e) => e.color.toARGB32())
135+
.toList(),
134136
);
135137
_addIfNonNull(
136138
json,

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,8 +1107,9 @@ class PinConfig extends BitmapDescriptor {
11071107
Object toJson() => <Object>[
11081108
type,
11091109
<String, Object?>{
1110-
if (backgroundColor != null) 'backgroundColor': backgroundColor?.value,
1111-
if (borderColor != null) 'borderColor': borderColor?.value,
1110+
if (backgroundColor != null)
1111+
'backgroundColor': backgroundColor?.toARGB32(),
1112+
if (borderColor != null) 'borderColor': borderColor?.toARGB32(),
11121113
if (glyph != null) 'glyph': glyph?.toJson(),
11131114
},
11141115
];
@@ -1131,7 +1132,7 @@ class CircleGlyph extends AdvancedMarkerGlyph {
11311132
@override
11321133
Object toJson() => <Object>[
11331134
'circleGlyph',
1134-
<String, Object>{'color': color.value},
1135+
<String, Object>{'color': color.toARGB32()},
11351136
];
11361137
}
11371138

@@ -1175,7 +1176,7 @@ class TextGlyph extends AdvancedMarkerGlyph {
11751176
'textGlyph',
11761177
<String, Object>{
11771178
'text': text,
1178-
if (textColor != null) 'textColor': textColor!.value,
1179+
if (textColor != null) 'textColor': textColor!.toARGB32(),
11791180
},
11801181
];
11811182
}

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ class Circle implements MapsObject<Circle> {
121121

122122
addIfPresent('circleId', circleId.value);
123123
addIfPresent('consumeTapEvents', consumeTapEvents);
124-
addIfPresent('fillColor', fillColor.value);
124+
addIfPresent('fillColor', fillColor.toARGB32());
125125
addIfPresent('center', center.toJson());
126126
addIfPresent('radius', radius);
127-
addIfPresent('strokeColor', strokeColor.value);
127+
addIfPresent('strokeColor', strokeColor.toARGB32());
128128
addIfPresent('strokeWidth', strokeWidth);
129129
addIfPresent('visible', visible);
130130
addIfPresent('zIndex', zIndex);

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class HeatmapGradient {
293293

294294
addIfPresent(
295295
'colors',
296-
colors.map((HeatmapGradientColor e) => e.color.value).toList(),
296+
colors.map((HeatmapGradientColor e) => e.color.toARGB32()).toList(),
297297
);
298298
addIfPresent(
299299
'startPoints',

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ class Polygon implements MapsObject<Polygon> {
141141

142142
addIfPresent('polygonId', polygonId.value);
143143
addIfPresent('consumeTapEvents', consumeTapEvents);
144-
addIfPresent('fillColor', fillColor.value);
144+
addIfPresent('fillColor', fillColor.toARGB32());
145145
addIfPresent('geodesic', geodesic);
146-
addIfPresent('strokeColor', strokeColor.value);
146+
addIfPresent('strokeColor', strokeColor.toARGB32());
147147
addIfPresent('strokeWidth', strokeWidth);
148148
addIfPresent('visible', visible);
149149
addIfPresent('zIndex', zIndex);

packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Polyline implements MapsObject<Polyline> {
171171

172172
addIfPresent('polylineId', polylineId.value);
173173
addIfPresent('consumeTapEvents', consumeTapEvents);
174-
addIfPresent('color', color.value);
174+
addIfPresent('color', color.toARGB32());
175175
addIfPresent('endCap', endCap.toJson());
176176
addIfPresent('geodesic', geodesic);
177177
addIfPresent('jointType', jointType.value);

packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.14.0
7+
version: 2.14.1
88

99
environment:
1010
sdk: ^3.8.0

packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ void main() {
784784
expect(pinConfig.toJson(), <Object>[
785785
PinConfig.type,
786786
<String, Object>{
787-
'backgroundColor': Colors.green.value,
788-
'borderColor': Colors.blue.value,
787+
'backgroundColor': Colors.green.toARGB32(),
788+
'borderColor': Colors.blue.toARGB32(),
789789
},
790790
]);
791791
});
@@ -802,11 +802,14 @@ void main() {
802802
expect(pinConfig.toJson(), <Object>[
803803
PinConfig.type,
804804
<String, Object>{
805-
'backgroundColor': Colors.green.value,
806-
'borderColor': Colors.blue.value,
805+
'backgroundColor': Colors.green.toARGB32(),
806+
'borderColor': Colors.blue.toARGB32(),
807807
'glyph': <Object>[
808808
'textGlyph',
809-
<Object, Object>{'text': 'Hello', 'textColor': Colors.red.value},
809+
<Object, Object>{
810+
'text': 'Hello',
811+
'textColor': Colors.red.toARGB32(),
812+
},
810813
],
811814
},
812815
]);
@@ -831,8 +834,8 @@ void main() {
831834
'bitmap': <Object>['fromAsset', 'red_square.png'],
832835
},
833836
],
834-
'backgroundColor': Colors.black.value,
835-
'borderColor': Colors.red.value,
837+
'backgroundColor': Colors.black.toARGB32(),
838+
'borderColor': Colors.red.toARGB32(),
836839
},
837840
]);
838841
});

packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/heatmap_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void main() {
303303

304304
expect(gradient.toJson(), <String, Object?>{
305305
'colors': colors
306-
.map((HeatmapGradientColor e) => e.color.value)
306+
.map((HeatmapGradientColor e) => e.color.toARGB32())
307307
.toList(),
308308
'startPoints': colors
309309
.map((HeatmapGradientColor e) => e.startPoint)

0 commit comments

Comments
 (0)