colorScheme static method
Returns SfColorScheme based on the useMaterial3
.
Implementation
static SfColorScheme colorScheme(BuildContext context) {
final ThemeData themeData = Theme.of(context);
if (themeData.useMaterial3) {
return SfColorScheme.m3(
useMaterial3: themeData.useMaterial3,
brightness: themeData.brightness,
primary: themeData.colorScheme.primary,
onPrimary: themeData.colorScheme.onPrimary,
primaryContainer: themeData.colorScheme.primaryContainer,
secondaryContainer: themeData.colorScheme.secondaryContainer,
surface: themeData.colorScheme.surface,
onSurface: themeData.colorScheme.onSurface,
surfaceVariant: themeData.colorScheme.surfaceContainerHighest,
onSurfaceVariant: themeData.colorScheme.onSurfaceVariant,
inverseSurface: themeData.colorScheme.inverseSurface,
onInverseSurface: themeData.colorScheme.onInverseSurface,
outline: themeData.colorScheme.outline,
outlineVariant: themeData.colorScheme.outlineVariant,
textColor: themeData.colorScheme.onSurface,
splashColor: themeData.splashColor,
hoverColor: themeData.hoverColor,
highlightColor: themeData.highlightColor,
valueIndicatorColor: Colors.transparent,
transparent: Colors.transparent,
scrim: themeData.colorScheme.scrim,
palettes: _palettesM3(themeData),
);
} else {
return SfColorScheme.m2(
useMaterial3: themeData.useMaterial3,
brightness: themeData.brightness,
primary: themeData.colorScheme.primary,
onPrimary: themeData.colorScheme.onPrimary,
primaryContainer: themeData.colorScheme.primaryContainer,
secondaryContainer: themeData.colorScheme.secondaryContainer,
surface: themeData.colorScheme.surface,
onSurface: themeData.colorScheme.onSurface,
surfaceVariant: themeData.colorScheme.surfaceContainerHighest,
onSurfaceVariant: themeData.colorScheme.onSurfaceVariant,
inverseSurface: themeData.colorScheme.inverseSurface,
onInverseSurface: themeData.colorScheme.onInverseSurface,
outline: themeData.colorScheme.outline,
outlineVariant: themeData.colorScheme.outlineVariant,
textColor: themeData.colorScheme.onSurface,
splashColor: themeData.splashColor,
hoverColor: themeData.hoverColor,
highlightColor: themeData.highlightColor,
valueIndicatorColor: Colors.transparent,
transparent: Colors.transparent,
palettes: _palettesM2(),
);
}
}