ThemeData constructor
ThemeData({
- Brightness? brightness,
- VisualDensity? visualDensity,
- Typography? typography,
- String? fontFamily,
- AccentColor? accentColor,
- Color? activeColor,
- Color? inactiveColor,
- Color? inactiveBackgroundColor,
- Color? disabledColor,
- Color? scaffoldBackgroundColor,
- Color? acrylicBackgroundColor,
- Color? shadowColor,
- ButtonState<
MouseCursor> ? inputMouseCursor, - Duration? fasterAnimationDuration,
- Duration? fastAnimationDuration,
- Duration? mediumAnimationDuration,
- Duration? slowAnimationDuration,
- Curve? animationCurve,
- BottomSheetThemeData? bottomSheetTheme,
- ButtonThemeData? buttonTheme,
- CheckboxThemeData? checkboxTheme,
- ChipThemeData? chipTheme,
- ToggleSwitchThemeData? toggleSwitchTheme,
- IconThemeData? iconTheme,
- SplitButtonThemeData? splitButtonTheme,
- ContentDialogThemeData? dialogTheme,
- TooltipThemeData? tooltipTheme,
- DividerThemeData? dividerTheme,
- RadioButtonThemeData? radioButtonTheme,
- ToggleButtonThemeData? toggleButtonTheme,
- SliderThemeData? sliderTheme,
- InfoBarThemeData? infoBarTheme,
- PillButtonBarThemeData? pillButtonBarTheme,
- FocusThemeData? focusTheme,
- ScrollbarThemeData? scrollbarTheme,
- SnackbarThemeData? snackbarTheme,
Implementation
factory ThemeData({
Brightness? brightness,
VisualDensity? visualDensity,
Typography? typography,
String? fontFamily,
AccentColor? accentColor,
Color? activeColor,
Color? inactiveColor,
Color? inactiveBackgroundColor,
Color? disabledColor,
Color? scaffoldBackgroundColor,
Color? acrylicBackgroundColor,
Color? shadowColor,
ButtonState<MouseCursor>? inputMouseCursor,
Duration? fasterAnimationDuration,
Duration? fastAnimationDuration,
Duration? mediumAnimationDuration,
Duration? slowAnimationDuration,
Curve? animationCurve,
BottomNavigationThemeData? bottomNavigationTheme,
BottomSheetThemeData? bottomSheetTheme,
ButtonThemeData? buttonTheme,
CheckboxThemeData? checkboxTheme,
ChipThemeData? chipTheme,
ToggleSwitchThemeData? toggleSwitchTheme,
IconThemeData? iconTheme,
SplitButtonThemeData? splitButtonTheme,
ContentDialogThemeData? dialogTheme,
TooltipThemeData? tooltipTheme,
DividerThemeData? dividerTheme,
NavigationPaneThemeData? navigationPaneTheme,
RadioButtonThemeData? radioButtonTheme,
ToggleButtonThemeData? toggleButtonTheme,
SliderThemeData? sliderTheme,
InfoBarThemeData? infoBarTheme,
PillButtonBarThemeData? pillButtonBarTheme,
FocusThemeData? focusTheme,
ScrollbarThemeData? scrollbarTheme,
SnackbarThemeData? snackbarTheme,
}) {
brightness ??= Brightness.light;
visualDensity ??= VisualDensity.adaptivePlatformDensity;
fasterAnimationDuration ??= Duration(milliseconds: 90);
fastAnimationDuration ??= Duration(milliseconds: 150);
mediumAnimationDuration ??= Duration(milliseconds: 300);
slowAnimationDuration ??= Duration(milliseconds: 500);
animationCurve ??= standartCurve;
accentColor ??= Colors.blue;
activeColor ??= Colors.white;
inactiveColor ??= AccentColor('normal', {
'normal': Colors.black,
'dark': Colors.white,
}).resolveFromBrightness(brightness);
inactiveBackgroundColor ??= AccentColor('normal', {
'normal': Color(0xFFd6d6d6),
'dark': Color(0xFF292929),
}).resolveFromBrightness(brightness);
disabledColor ??= AccentColor('normal', {
'normal': const Color(0xFF838383),
'dark': Colors.grey[80].withOpacity(0.6)
});
shadowColor ??= AccentColor('normal', {
'normal': Colors.black,
'dark': Colors.grey[130],
}).resolveFromBrightness(brightness);
scaffoldBackgroundColor ??= AccentColor('normal', {
'normal': Colors.white,
'dark': Colors.black,
}).resolveFromBrightness(brightness);
acrylicBackgroundColor ??= AccentColor('normal', {
'normal': Color.fromARGB(204, 255, 255, 255),
'dark': Color(0x7F1e1e1e),
}).resolveFromBrightness(brightness);
typography = Typography.standard(brightness: brightness)
.merge(typography)
.apply(fontFamily: fontFamily);
inputMouseCursor ??= ButtonState.resolveWith((states) {
if (states.isHovering || states.isPressing)
return SystemMouseCursors.click;
else
return MouseCursor.defer;
});
focusTheme = FocusThemeData.standard(
glowColor: accentColor.withOpacity(0.15),
primaryBorderColor: inactiveColor,
secondaryBorderColor: scaffoldBackgroundColor,
).merge(focusTheme);
buttonTheme ??= const ButtonThemeData();
checkboxTheme ??= const CheckboxThemeData();
chipTheme ??= const ChipThemeData();
toggleButtonTheme ??= const ToggleButtonThemeData();
toggleSwitchTheme ??= const ToggleSwitchThemeData();
iconTheme ??= brightness.isDark
? const IconThemeData(color: Colors.white, size: 18.0)
: const IconThemeData(color: Colors.black, size: 18.0);
splitButtonTheme ??= const SplitButtonThemeData();
dialogTheme ??= const ContentDialogThemeData();
tooltipTheme ??= const TooltipThemeData();
dividerTheme ??= const DividerThemeData();
navigationPaneTheme ??= NavigationPaneThemeData.standard(
animationCurve: animationCurve,
animationDuration: fastAnimationDuration,
backgroundColor: acrylicBackgroundColor,
disabledColor: disabledColor,
highlightColor: accentColor,
inputMouseCursor: inputMouseCursor,
typography: typography,
inactiveColor: inactiveColor,
);
radioButtonTheme ??= const RadioButtonThemeData();
sliderTheme ??= const SliderThemeData();
infoBarTheme ??= const InfoBarThemeData();
pillButtonBarTheme ??= const PillButtonBarThemeData();
scrollbarTheme ??= const ScrollbarThemeData();
bottomNavigationTheme ??= const BottomNavigationThemeData();
snackbarTheme ??= const SnackbarThemeData();
bottomSheetTheme ??= const BottomSheetThemeData();
return ThemeData.raw(
brightness: brightness,
visualDensity: visualDensity,
fasterAnimationDuration: fasterAnimationDuration,
fastAnimationDuration: fastAnimationDuration,
mediumAnimationDuration: mediumAnimationDuration,
slowAnimationDuration: slowAnimationDuration,
animationCurve: animationCurve,
accentColor: accentColor,
activeColor: activeColor,
inactiveColor: inactiveColor,
inactiveBackgroundColor: inactiveBackgroundColor,
disabledColor: disabledColor,
scaffoldBackgroundColor: scaffoldBackgroundColor,
acrylicBackgroundColor: acrylicBackgroundColor,
shadowColor: shadowColor,
bottomNavigationTheme: bottomNavigationTheme,
buttonTheme: buttonTheme,
checkboxTheme: checkboxTheme,
chipTheme: chipTheme,
dialogTheme: dialogTheme,
dividerTheme: dividerTheme,
focusTheme: focusTheme,
iconTheme: iconTheme,
infoBarTheme: infoBarTheme,
navigationPaneTheme: navigationPaneTheme,
radioButtonTheme: radioButtonTheme,
scrollbarTheme: scrollbarTheme,
sliderTheme: sliderTheme,
splitButtonTheme: splitButtonTheme,
toggleButtonTheme: toggleButtonTheme,
toggleSwitchTheme: toggleSwitchTheme,
tooltipTheme: tooltipTheme,
typography: typography,
inputMouseCursor: inputMouseCursor,
snackbarTheme: snackbarTheme,
pillButtonBarTheme: pillButtonBarTheme,
bottomSheetTheme: bottomSheetTheme,
);
}