flutter/packages
Mitchell Goodwin 54573bc875
Have Material widgets in a Cupertino App partially use Cupertino theme (#139253)
Fixes #138621

Fixes and issue where if a Material widget is used in a Cupertino App, then some parts of it's default Material 3 theming would show up as purplish. This could be fixed by wrapping your app with a Material theme, but that's a little awkward.

Material and Cupertino themes interact with each other a little oddly. If a theme of either is searched for but does not exist, then a default one is generated. So if a Material widget is in a Cupertino app that does not already have a Material theme, then a fallback Material theme will be created. This PR makes it so that, in this case when that Material theme is created, it's default colors will be based on the Cupertino theme.

Another oddity is that a Material theme always wraps itself with a Cupertino theme that's values are based on the Material theme. So before this change, a Material widget would theoretically add a new Material based Cupertino theme to the tree. So I added logic that would have the Material theme check to see if a Cupertino theme exists, before it overwrites it.

Before:
![image](https://github.com/flutter/flutter/assets/58190796/95874076-e943-48fa-ba9d-1d7b0f5a2f38)

After:
<img width="386" alt="Screenshot 2023-11-29 at 10 37 09 AM" src="https://github.com/flutter/flutter/assets/58190796/959ccfd9-3439-438e-ad36-20597334837a">

Update:
I changed it to not rely on the Material 3 flag. Instead, if a Material theme is searched for and there is already a Cupertino theme in the tree, then it will use that Cupertino theme instead of generating a new. Also, if a Material theme is searched for, and it does not find one already in the tree, but does find a Cupertino theme, then it will generate one with a color palette based off of that Cupertino theme's colors.

After with this change:
<img width="390" alt="Screenshot 2024-05-09 at 10 16 22 AM" src="https://github.com/flutter/flutter/assets/58190796/79765d04-a7a3-4eb5-9477-11668ed138e5">

We should still probably suggest for developers to include a Material theme in their Cupertino app if they wish to use widgets from both packages.
2024-05-30 17:54:53 +00:00
..
flutter Have Material widgets in a Cupertino App partially use Cupertino theme (#139253) 2024-05-30 17:54:53 +00:00
flutter_driver Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
flutter_goldens Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
flutter_localizations Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
flutter_test Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
flutter_tools Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
flutter_web_plugins Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
fuchsia_remote_debug_protocol Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
integration_test Manual roll Flutter Engine from 60968ee3bde7 to 8d5d14a1db95 (1 revision) (#149263) 2024-05-30 00:53:23 +00:00
analysis_options.yaml