-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dynamic_color] Add tone-based colors to color scheme #599
base: main
Are you sure you want to change the base?
Conversation
I'm trying to use this, but I get this error: |
Interesting...I don't think I've changed anything related to that. Does the latest main branch work fine for you? |
Well, from pub it doesn't have the correct colours, but no errors. I switched the pubspec to use this fork, and boom: error. I'll try main asap. |
Latest main works fine. Just this branch :) |
I'm using DynamicColorBuilder ofc. |
Which flutter version are you using? |
|
Ok, I think I see the problem. Support for arbitrary colour tones were added in material_color_utilities 0.11.0, but stable flutter depends on 0.8.0. I just realised I was using the beta channel, which is why I didn't run into it. I think the solution will be to sidestep material_color_utilities and try to get the colours from the native side for the API < 34 case as well. |
Oh, I see, thanks! |
I've taken a different approach of implementing logic to "guess" tones that are missing from the common tones list, based on the implementation in material_color_utilities. This will be needed until flutter supports the new version. @Henry-Hiles Can you confirm if this works for you now? |
Sure, I'll test right now! |
While this no longer has an error, it still has the same issues as without this PR (very similar colors so nothing looks correct) |
As you can see, the navbar and background are the same, which isn't normal. |
Nevermind deleting pub cache and re-getting fixed it! Thank you for this! |
Which android version are you using? |
Android 14. I could give the project to you try it out seeing what's wrong |
On Android 14, this should be using the primary colour that is provided directly by the system. Could you share your flutter version, debug logs and a sample project if possible. |
Here's the link to the project where I ran the test: https://github.com/JunioJsv/minimum-flutter |
I'm not able to reproduce the issue on my device. Could you share the debug logs when you run the app. In particular, do you see a line similar to:
|
It seems this may be a common issue on Samsung devices, affecting the official Android material library as well - material-components/material-components-android#3924. Samsung reports incorrect values for the new colours added in Android 14. Do you see dynamic colours working correctly in other apps, e.g. Google apps? Given this is a Samsung specific issue, not really sure what we can do here. |
Indeed, the Google apps are also displaying the wrong tone, dark blue, and my device is a Samsung A54. |
I've decided to finally publish a "just build it" branch of my project: https://github.com/resucutie/localbooru/tree/dynamic-colors-pr-fix-test @hasali19 feel free to build and test it |
@resucutie Thanks, I'll take a look. Could you also share your flutter version please? |
From what I can see this is working as expected; Android's quick settings tiles use a slightly different shade of the primary colour. You can see here that the |
Welp, what about in comparasion to other apps? It looks odd, or I guess it is the consensus here, like if it is using the wrong color shade, but I am not sure |
Do you mean you are seeing different colours compared to other apps using the same dynamic colour scheme? This implementation should be using the same colours as those used by the official native material library. If this is not the case, please share a repro. |
in our case, after activating dynamic colors (using this commit): look at the cards (list a/b and the new list fab. they should be different colors but with dynamic colors they become the same) without dynamic colors (correct)with dynamic colors (wrong) |
Please can you share your flutter and android versions, device information, debug logs and a link to a code repo if possible. |
@hasali19 what would be the best way to ignore completely oneplus color presets, just get the "main accent color" from android and utilize that color to build a correct material 3 color palette? |
Thanks for the info. Given that you are using Android 14 where the colours are retrieved directly from the system without any conversion, it is likely OnePlus is simply reporting both colours as the same. One thing you could try is to force use of the fallback method used for older versions of Android, e.g: final corePalette = await DynamicColorPlugin.getCorePalette();
final lightDynamic = corePalette?.toColorScheme(brightness: Brightness.light);
final darkDynamic = corePalette?.toColorScheme(brightness: Brightness.dark); If you just want a specific "accent" colour, you can pick one from the fields on the colour schemes provided by |
update final corePalette = await DynamicColorPlugin.getCorePalette();
final lightDynamic = corePalette?.toColorScheme(brightness: Brightness.light);
final darkDynamic = corePalette?.toColorScheme(brightness: Brightness.dark); doesn't fix the issue my colleague tested with his Pixel 7 Pro (and also inside an emulator) and he has the same issue the issue seems to be present only in light mode tho (and our theme settings don't have any special settings for only one of the modes): wrong in light modecorrect in dark mode |
yeah i was just about to write it! they are a little different... so it's more of a general issue with the way the m3 color generator works? |
Right, I guess it's just an artifact of whatever algorithm Android uses to pick the system colours. |
well to be fair the material theme builder shows it as well with the blues (tho the difference is a little more visible): while with the greens the difference is much less subtle: @guidezpl is it supposed to be that different between hues? |
While `surfaceVariant` has been deprecated in favor of `surfaceContainerHighest`, the `dynamic_color` package does not yet support it, leading to an incorrect palette. Ignoring the deprecation warnings while waiting for material-foundation/flutter-packages#599.
Description
Adds the new tone-based colors from Flutter 3.22 to the color scheme.
On API >= 34, the color values are retrieved directly from the Android OS.
On API >= 31, the existing core palette will continue to be used, with the mappings taken from https://github.com/material-components/material-components-android/blob/master/docs/theming/Color.md.
Issues
Fixes #574, #582
Checklist
CHANGELOG.md