fromTheme static method
Implementation
static ThemeData fromTheme(ColorScheme base, ThemeModel theme) {
try {
var scheme = ColorScheme(
brightness:
theme.brightness == 'dark' ? Brightness.dark : Brightness.light,
background: theme.background ?? base.background,
onBackground: theme.onBackground ?? base.onBackground,
shadow: theme.shadow ?? base.shadow,
outline: theme.outline ?? base.outline,
surface: theme.surface ?? base.surface,
onSurface: theme.onSurface ?? base.onSurface,
surfaceVariant: theme.surfaceVariant ?? base.surfaceVariant,
onSurfaceVariant: theme.onSurfaceVariant ?? base.onSurfaceVariant,
inverseSurface: theme.inverseSurface ?? base.inverseSurface,
onInverseSurface: theme.onInverseSurface ?? base.onInverseSurface,
primary: theme.primary ?? base.primary,
onPrimary: theme.onPrimary ?? base.onPrimary,
primaryContainer: theme.primaryContainer ?? base.primaryContainer,
onPrimaryContainer: theme.onPrimaryContainer ?? base.onPrimaryContainer,
inversePrimary: theme.inversePrimary ?? base.inversePrimary,
secondary: theme.secondary ?? base.secondary,
onSecondary: theme.onSecondary ?? base.onSecondary,
secondaryContainer: theme.secondaryContainer ?? base.secondaryContainer,
onSecondaryContainer:
theme.onSecondaryContainer ?? base.onSecondaryContainer,
tertiaryContainer: theme.tertiaryContainer ?? base.tertiaryContainer,
onTertiaryContainer:
theme.onTertiaryContainer ?? base.onTertiaryContainer,
error: theme.error ?? base.error,
onError: theme.onError ?? base.onError,
errorContainer: theme.errorContainer ?? base.errorContainer,
onErrorContainer: theme.onErrorContainer ?? base.onErrorContainer,
);
return ThemeData.from(useMaterial3: true, colorScheme: scheme);
} catch (e) {
Log().exception(e);
return ThemeData.from(colorScheme: base, useMaterial3: true);
}
}