Using the material 3 theme builder custom colors we have 4 colors that we need to choose from: Primary, Secondary, Tertiary, Neutral.
The site then generates a full both light and dark scheme that is based on the colors.
After adding the material file to the app we can use them like that
Theme.of(context).colorScheme.primary;
In the bottom part of the custom material 3 theme builder there is part about tonal palettes ✨
Would love to use the generated tonal palettes.
I have tried Theme.of(context).colorScheme.primary[50];
and Theme.of(context).colorScheme.primary.shade50;
but it does not work.
How can I use the material 3 generated tonal palette?.
2
Answers
Answer:
The generated material 3 does not bundle inside of the Theme of the app as far as I know but the good news is that you can generate it yourself from each of your colors.
Add the following package: material_color_utilities
Insert your primary color in
_primaryColor
to get the primary color tonal paletteAnd repeat for each main color in the material 3 colors
Bonus:
You can also generate all the material 3 theme in the app programmatically from 5 colors.
Neutral on the left is not the same as generated Neutral as shown in the image
You will need the following packages: dynamic_color, material_color_utilities
Insert your values in
_primaryColor
,_secondaryColor
,_tertiaryColor
,_neutralColor
,_neutralVariantColor
Add material_color_utilities pacakge