BaseThemeData constructor
BaseThemeData({
- Brightness? brightness,
- double? appBarHeight,
- bool appBarBackdropFilter = true,
- bool appBarTransitionBetweenRoutes = true,
- ThemeData? materialTheme,
- ThemeData? materialDarkTheme,
- ThemeData? materialHighContrastTheme,
- ThemeData? materialHighContrastDarkTheme,
- CupertinoThemeData? cupertinoTheme,
- bool useMaterial3 = true,
- bool routeFullscreenGackGesture = false,
- Color? sectionDividerColor,
- Color? tileBackgroundColor,
- BasePlatformMode? platformMode = const BasePlatformMode(),
- bool withoutSplashOnCupertino = true,
- BaseParam? baseParam,
Implementation
factory BaseThemeData({
Brightness? brightness,
double? appBarHeight,
bool appBarBackdropFilter = true,
bool appBarTransitionBetweenRoutes = true,
ThemeData? materialTheme,
ThemeData? materialDarkTheme,
ThemeData? materialHighContrastTheme,
ThemeData? materialHighContrastDarkTheme,
CupertinoThemeData? cupertinoTheme,
bool useMaterial3 = true,
bool routeFullscreenGackGesture = false,
Color? sectionDividerColor,
Color? tileBackgroundColor,
BasePlatformMode? platformMode = const BasePlatformMode(),
bool withoutSplashOnCupertino = true,
BaseParam? baseParam,
}) {
brightness ??= Brightness.light;
final bool isDark = brightness == Brightness.dark;
// Create default Material 3 themes if not provided and useMaterial3 is true
if (useMaterial3 && materialTheme == null) {
materialTheme = ThemeData(
brightness: Brightness.light,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.light,
),
// Ensure proper default text styling to prevent yellow underlines
textTheme: ThemeData.light().textTheme,
);
}
if (useMaterial3 && materialDarkTheme == null) {
materialDarkTheme = ThemeData(
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.dark,
),
// Ensure proper default text styling to prevent yellow underlines
textTheme: ThemeData.dark().textTheme,
);
}
// Ensure any provided themes have proper text styling
if (materialTheme != null) {
// Only modify if the theme doesn't already have a complete textTheme
if (materialTheme.textTheme.bodyMedium?.decoration != TextDecoration.none) {
materialTheme = materialTheme.copyWith(
textTheme: ThemeData.light().textTheme,
);
}
}
if (materialDarkTheme != null) {
// Only modify if the theme doesn't already have a complete textTheme
if (materialDarkTheme.textTheme.bodyMedium?.decoration != TextDecoration.none) {
materialDarkTheme = materialDarkTheme.copyWith(
textTheme: ThemeData.dark().textTheme,
);
}
}
return BaseThemeData.raw(
brightness: brightness,
appBarHeight: appBarHeight,
appBarBackdropFilter: appBarBackdropFilter,
appBarTransitionBetweenRoutes: appBarTransitionBetweenRoutes,
materialTheme: materialTheme,
materialDarkTheme: materialDarkTheme,
materialHighContrastTheme: materialHighContrastTheme,
materialHighContrastDarkTheme: materialHighContrastDarkTheme,
cupertinoTheme: cupertinoTheme,
useMaterial3: useMaterial3,
routeFullscreenGackGesture: routeFullscreenGackGesture,
sectionDividerColor: sectionDividerColor ?? (isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000)),
tileBackgroundColor: tileBackgroundColor,
platformMode: platformMode,
withoutSplashOnCupertino: withoutSplashOnCupertino,
baseParam: baseParam,
);
}