shadMaterialThemeFrom function
Derives the Material ThemeData a ShadThemeData implies.
ShadApp does this at the root so that Material widgets — and the ambient
DefaultTextStyle and IconTheme that every Text and Icon reads from —
agree with the Shad theme. Exposed so a subtree can be re-themed too; see
ShadThemeScope.
Implementation
ThemeData shadMaterialThemeFrom(ShadThemeData themeData) {
return ThemeData(
fontFamily: themeData.textTheme.family,
colorScheme: ColorScheme(
brightness: themeData.brightness,
primary: themeData.colorScheme.primary,
onPrimary: themeData.colorScheme.primaryForeground,
secondary: themeData.colorScheme.secondary,
onSecondary: themeData.colorScheme.secondaryForeground,
error: themeData.colorScheme.destructive,
onError: themeData.colorScheme.destructiveForeground,
surface: themeData.colorScheme.background,
onSurface: themeData.colorScheme.foreground,
),
scaffoldBackgroundColor: themeData.colorScheme.background,
brightness: themeData.brightness,
dividerTheme: DividerThemeData(
color: themeData.separatorTheme.color ?? themeData.colorScheme.border,
thickness: themeData.separatorTheme.thickness ?? 1,
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: themeData.colorScheme.primary,
selectionColor: themeData.colorScheme.selection,
selectionHandleColor: themeData.colorScheme.primary,
),
iconTheme: IconThemeData(
size: 16,
color: themeData.colorScheme.foreground,
),
scrollbarTheme: ScrollbarThemeData(
crossAxisMargin: 1,
mainAxisMargin: 1,
thickness: const WidgetStatePropertyAll(8),
radius: const Radius.circular(999),
thumbColor: WidgetStatePropertyAll(themeData.colorScheme.border),
),
);
}