Skip to content

Commit 2fbf78d

Browse files
[google_maps_flutter] Add color scheme support to platform interface (#11278)
Platform interface portion of #10471 Part of flutter/flutter#176445 ## 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 90a2dc1 commit 2fbf78d

6 files changed

Lines changed: 56 additions & 3 deletions

File tree

packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.15.0
2+
3+
* Adds support for `colorScheme` for cloud-based maps styling brightness in web.
4+
15
## 2.14.2
26

37
* Adds documentation about iOS rendering issue with `PinConfig`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// The color scheme of the map to be used with cloud styles.
6+
enum MapColorScheme {
7+
/// The light color scheme for the map.
8+
light,
9+
10+
/// The dark color scheme for the map.
11+
dark,
12+
13+
/// The system default color scheme for the map.
14+
followSystem,
15+
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class MapConfiguration {
4242
String? cloudMapId,
4343
this.style,
4444
this.markerType,
45+
this.colorScheme,
4546
}) : mapId = mapId ?? cloudMapId;
4647

4748
/// This setting controls how the API handles gestures on the map. Web only.
@@ -143,6 +144,11 @@ class MapConfiguration {
143144
/// used.
144145
final MarkerType? markerType;
145146

147+
/// Preferred color scheme for the cloud-styled map. Web only.
148+
///
149+
/// See https://developers.google.com/maps/documentation/javascript/mapcolorscheme for more details.
150+
final MapColorScheme? colorScheme;
151+
146152
/// Identifier that's associated with a specific cloud-based map style.
147153
///
148154
/// See https://developers.google.com/maps/documentation/get-map-id
@@ -227,6 +233,7 @@ class MapConfiguration {
227233
mapId: mapId != other.mapId ? mapId : null,
228234
style: style != other.style ? style : null,
229235
markerType: markerType != other.markerType ? markerType : null,
236+
colorScheme: colorScheme != other.colorScheme ? colorScheme : null,
230237
);
231238
}
232239

@@ -265,6 +272,7 @@ class MapConfiguration {
265272
mapId: diff.mapId ?? mapId,
266273
style: diff.style ?? style,
267274
markerType: diff.markerType ?? markerType,
275+
colorScheme: diff.colorScheme ?? colorScheme,
268276
);
269277
}
270278

@@ -294,7 +302,8 @@ class MapConfiguration {
294302
buildingsEnabled == null &&
295303
mapId == null &&
296304
style == null &&
297-
markerType == null;
305+
markerType == null &&
306+
colorScheme == null;
298307

299308
@override
300309
bool operator ==(Object other) {
@@ -329,7 +338,8 @@ class MapConfiguration {
329338
buildingsEnabled == other.buildingsEnabled &&
330339
mapId == other.mapId &&
331340
style == other.style &&
332-
markerType == other.markerType;
341+
markerType == other.markerType &&
342+
colorScheme == other.colorScheme;
333343
}
334344

335345
@override
@@ -359,6 +369,7 @@ class MapConfiguration {
359369
mapId,
360370
style,
361371
markerType,
372+
colorScheme,
362373
]);
363374
}
364375

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export 'heatmap.dart';
1919
export 'heatmap_updates.dart';
2020
export 'joint_type.dart';
2121
export 'location.dart';
22+
export 'map_color_scheme.dart';
2223
export 'map_configuration.dart';
2324
export 'map_objects.dart';
2425
export 'map_widget_configuration.dart';

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.2
7+
version: 2.15.0
88

99
environment:
1010
sdk: ^3.9.0

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,22 @@ void main() {
485485
// The hash code should change.
486486
expect(empty.hashCode, isNot(diff.hashCode));
487487
});
488+
489+
test('handle colorScheme', () async {
490+
const diff = MapConfiguration(colorScheme: MapColorScheme.followSystem);
491+
492+
const empty = MapConfiguration();
493+
final MapConfiguration updated = diffBase.applyDiff(diff);
494+
495+
// A diff applied to empty options should be the diff itself.
496+
expect(empty.applyDiff(diff), diff);
497+
// The diff from empty options should be the diff itself.
498+
expect(diff.diffFrom(empty), diff);
499+
// A diff applied to non-empty options should update that field.
500+
expect(updated.colorScheme, MapColorScheme.followSystem);
501+
// The hash code should change.
502+
expect(empty.hashCode, isNot(diff.hashCode));
503+
});
488504
});
489505

490506
group('isEmpty', () {
@@ -641,5 +657,11 @@ void main() {
641657

642658
expect(diff.isEmpty, false);
643659
});
660+
661+
test('is false with colorScheme', () async {
662+
const diff = MapConfiguration(colorScheme: MapColorScheme.followSystem);
663+
664+
expect(diff.isEmpty, false);
665+
});
644666
});
645667
}

0 commit comments

Comments
 (0)