Closed lien-dkseo closed 3 weeks ago
Here is how I would use it:
ThemeData darkMediumContrast() { // Update the other similar methods also
return theme(darkMediumContrastScheme().toColorScheme(),
divider: MaterialTheme.divider.darkMediumContrast);
}
ThemeData theme(ColorScheme colorScheme, {required ColorFamily divider}) =>
ThemeData(
useMaterial3: true,
brightness: colorScheme.brightness,
colorScheme: colorScheme,
textTheme: textTheme.apply(
bodyColor: divider.color, // Example
displayColor: divider.onColor,
)
)
);
@bhargavweb thank you~.
I edited the question.
divider
-> customColor1, customColor2, ...
I want to use it like this....
Theme.of(context).....customColor1.onColor
Theme.of(context).....customColor1.colorContainer
Icon(
Icons.warning_amber,
color: Theme.of(context).colorScheme.primary, // like this... Theme.of(context).....customColor1.onColor
),
What you are describing sounds like Theme Extensions: https://api.flutter.dev/flutter/material/ThemeExtension-class.html
Which solution you choose can be determined by your needs (e.g. will the color be the same across light, dark, and contrast levels or need to be contrast aware)
how to use 'static const customColor1, 2, ...' or 'get extendedColors' in flutter ?