Skip to content
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

How to build a DynamicScheme from a CorePalette? #148

Open
amal-stack opened this issue Apr 17, 2024 · 0 comments
Open

How to build a DynamicScheme from a CorePalette? #148

amal-stack opened this issue Apr 17, 2024 · 0 comments

Comments

@amal-stack
Copy link

Earlier, given a CorePalette, the way to generate the Material color roles was to use Scheme.lightFromCorePalette and Scheme.darkFromCorePalette.

Currently, since Scheme is deprecated in favor of DynamicScheme, what is the way to generate a DyanamicScheme or to obtain color roles given a CorePalette? Is the CorePalette class still relevant or will it be deprecated?

I'm currently using the dynamic_color package for Dart that obtains a CorePalette from Android systems using DynamicColorPlugin.getCorePalette. However, the DynamicColorBuilder widget uses Scheme.lightFromCorePalette and Scheme.darkFromCorePalette to create the color roles and maps it to the Flutter ColorScheme. The deprecated Scheme class does not have the new surface roles( like surfaceContainer) and the fixed roles (like primaryFixed). Flutter has added these new roles to the ColorScheme class (in the beta release) but the Scheme methods do not assign these color roles. So, when I use these new roles in my app, their colors are always null.

DynamicColorBuilder (from the dynamic_color package) is a simple widget that calls DynamicColorPlugin.getCorePalette and maps it to a flutter ColorScheme. So, I can write my own implementation until the dynamic_color package is updated to use the new DynamicScheme classes. In the meantime, if I obtain the Android platform's CorePalette using DynamicColorPlugin.getCorePalette, how can I convert it to a DynamicScheme and obtain the color roles from it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant