Skip to content

[google_maps_flutter] Add MapColorScheme support to Android and iOS#11736

Open
snaeji wants to merge 1 commit into
flutter:mainfrom
snaeji:colorscheme-mobile-support-v2
Open

[google_maps_flutter] Add MapColorScheme support to Android and iOS#11736
snaeji wants to merge 1 commit into
flutter:mainfrom
snaeji:colorscheme-mobile-support-v2

Conversation

@snaeji
Copy link
Copy Markdown

@snaeji snaeji commented May 19, 2026

Description

Wires up MapColorScheme (light/dark/followSystem) to native APIs on Android and iOS. The platform interface and app-facing google_maps_flutter package already exposed this parameter (added in 2.16.0 for web), but the Android and iOS plugins silently ignored it.

  • Android: GoogleMap.setMapColorScheme() is invoked with the matching MapColorScheme constant. Both creation-time and runtime updates (via interpretMapConfiguration) are supported.
  • iOS: GMSMapView.overrideUserInterfaceStyle is set to UIUserInterfaceStyleLight / Dark / Unspecified — the documented API per the Google Maps SDK for iOS.

The change is mirrored across google_maps_flutter_ios, google_maps_flutter_ios_sdk9, google_maps_flutter_ios_sdk10, and google_maps_flutter_ios_shared_code via dart tool/sync_shared_files.dart.

The colorScheme doc comment in google_maps_flutter and google_maps_flutter_platform_interface is updated to reflect the new platform support (previously documented as "Web only").

Tests added:

  • Android: Convert.toMapColorScheme JUnit tests for all three enum values; interpretMapConfiguration_handlesColorScheme dispatcher test mirroring _handlesStyle; Dart-side creation-params test asserting colorScheme flows through to the platform view.
  • iOS: Parametrized Dart-side creation-params tests covering light, dark, followSystem, and null; matching tests propagated to sdk9 and sdk10 via the shared-code sync.

Fixes flutter/flutter#186737

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  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. 2

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@snaeji snaeji force-pushed the colorscheme-mobile-support-v2 branch from 4da8e36 to 23d6cae Compare May 19, 2026 11:29
@snaeji snaeji marked this pull request as ready for review May 19, 2026 11:36
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements colorScheme support for cloud-based maps styling brightness on Android and iOS, extending the existing web functionality. The updates span the platform interface, native platform implementations, and Pigeon message definitions. A review comment correctly identifies that the documentation for colorScheme should be updated to reflect that it can be modified after map creation on iOS, aligning the documentation with the new implementation.

Comment thread packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart Outdated
Wire up MapColorScheme (light/dark/followSystem) to native APIs on
both mobile platforms. The platform interface and app-facing package
already support this parameter (added in 2.16.0 for web), but the
Android and iOS plugins silently ignored it.

Android: Uses GoogleMap.setMapColorScheme() with MapColorScheme
constants. Handles both creation-time and runtime updates.

iOS: Maps to UIView.overrideUserInterfaceStyle (light/dark/unspecified)
on the GMSMapView, matching the Google Maps SDK for iOS documented
approach.

Changes per platform:
- Pigeon: Add PlatformMapColorScheme enum + field on PlatformMapConfiguration
- Dart: Add converter + wire into config mapper
- Native: Read field, convert to native API, apply at init and on update
- Tests: Convert mapper + dispatcher tests + creation-params plumbing

Updates app-facing google_maps_flutter and platform_interface doc
comments to reflect Android and iOS support (previously documented
as "Web only"). Mirrors changes to google_maps_flutter_ios_sdk9,
google_maps_flutter_ios_sdk10, and google_maps_flutter_ios_shared_code
via dart tool/sync_shared_files.dart.
@snaeji snaeji force-pushed the colorscheme-mobile-support-v2 branch from 23d6cae to 1d4d137 Compare May 19, 2026 12:34
@stuartmorgan-g stuartmorgan-g added triage-ios Should be looked at in iOS triage triage-android Should be looked at in Android triage labels May 19, 2026
Copy link
Copy Markdown
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return PlatformMapColorScheme.followSystem;
}

// The enum comes from a different package, which could get a new value at
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe switch expressions / statements have to be exhaustive or it is gong to be a compile time error. The code isn't going to compile if there's an unhandled case. IOW the runtime error will never be reachable, unless you add a default case. But adding a new case to an existing enum should require a major version bump I think? So we don't really have to handle that at runtime.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this could just be an expression:

return switch (colorScheme) { 
  null => null,
  .light => .light,
  .dart => .dart,
  .followSystem => .followSystem,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why do we need 2 enums that represent the same thing? Can we just re-export one / making one of the an alias of the other? Then we don't need this since there's only one type under the hood.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe switch expressions / statements have to be exhaustive or it is gong to be a compile time error.

Switch expressions do, not arbitrary switch statements.

But adding a new case to an existing enum should require a major version bump I think?

We have not traditionally considered that to be a major version change. We may need to revisit that at some point as switch expressions become more common, but for now we don't (at least for platform interfaces).

So we don't really have to handle that at runtime.

We do, for the specific goal of not requiring breaking the platform interface all the time.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why do we need 2 enums that represent the same thing?

Because Pigeon definitions currently aren't allowed to import things from other files. And doing so in the case of an enum from another package would be extremely dangerous since it would allow for Dart code to change without the native side changing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: google_maps_flutter platform-android platform-ios triage-android Should be looked at in Android triage triage-ios Should be looked at in iOS triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_maps_flutter] colorScheme not wired up on Android and iOS

3 participants