MacosThemeData constructor
MacosThemeData({
- Brightness? brightness,
- Color? primaryColor,
- Color? canvasColor,
- MacosTypography? typography,
- PushButtonThemeData? pushButtonTheme,
- Color? dividerColor,
- HelpButtonThemeData? helpButtonTheme,
- TooltipThemeData? tooltipTheme,
- VisualDensity? visualDensity,
- ScrollbarThemeData? scrollbarTheme,
- MacosIconButtonThemeData? macosIconButtonThemeData,
- MacosIconThemeData? iconTheme,
- MacosPopupButtonThemeData? macosPopupButtonTheme,
- MacosTextFieldThemeData? textFieldTheme,
Creates a MacosThemeData that's used to configure MacosTheme.
The typography
TextStyle colors are black if the brightness
is Brightness.light, and white for Brightness.dark.
Unspecified parameters default to a reasonable macOS default style.
See also:
- MacosThemeData.light, which creates a light blue theme.
- MacosThemeData.dark, which creates a dark blue theme.
Implementation
factory MacosThemeData({
Brightness? brightness,
Color? primaryColor,
Color? canvasColor,
MacosTypography? typography,
PushButtonThemeData? pushButtonTheme,
Color? dividerColor,
HelpButtonThemeData? helpButtonTheme,
TooltipThemeData? tooltipTheme,
VisualDensity? visualDensity,
ScrollbarThemeData? scrollbarTheme,
MacosIconButtonThemeData? macosIconButtonThemeData,
MacosIconThemeData? iconTheme,
MacosPopupButtonThemeData? macosPopupButtonTheme,
MacosTextFieldThemeData? textFieldTheme,
}) {
final Brightness _brightness = brightness ?? Brightness.light;
final bool isDark = _brightness == Brightness.dark;
primaryColor ??= isDark
? CupertinoColors.activeBlue.darkColor
: CupertinoColors.activeBlue.color;
canvasColor ??= isDark
? CupertinoColors.systemBackground.darkElevatedColor
: CupertinoColors.systemBackground;
typography ??= MacosTypography(
color: brightness == Brightness.light
? CupertinoColors.black
: CupertinoColors.white,
);
pushButtonTheme ??= PushButtonThemeData(
color: primaryColor,
secondaryColor: isDark
? const Color.fromRGBO(56, 56, 56, 1.0)
: const Color.fromRGBO(218, 218, 223, 1.0),
disabledColor: isDark
? const Color.fromRGBO(255, 255, 255, 0.1)
: const Color.fromRGBO(244, 245, 245, 1.0),
);
dividerColor ??= isDark ? const Color(0x1FFFFFFF) : const Color(0x1F000000);
helpButtonTheme ??= HelpButtonThemeData(
color: isDark
? const Color.fromRGBO(255, 255, 255, 0.1)
: const Color.fromRGBO(244, 245, 245, 1.0),
disabledColor: isDark
? const Color.fromRGBO(255, 255, 255, 0.1)
: const Color.fromRGBO(244, 245, 245, 1.0),
);
tooltipTheme ??= TooltipThemeData.standard(
brightness: _brightness,
textStyle: typography.callout,
);
textFieldTheme ??= const MacosTextFieldThemeData();
scrollbarTheme ??= const ScrollbarThemeData();
macosIconButtonThemeData ??= MacosIconButtonThemeData(
backgroundColor: MacosColors.transparent,
disabledColor: isDark
? const Color(0xff353535)
: const Color(0xffE5E5E5), // TODO: correct disabled color
hoverColor: isDark ? const Color(0xff333336) : const Color(0xffF3F2F2),
shape: BoxShape.circle,
boxConstraints: const BoxConstraints(
minHeight: 20,
minWidth: 20,
maxWidth: 30,
maxHeight: 30,
),
);
visualDensity ??= VisualDensity.adaptivePlatformDensity;
iconTheme ??= MacosIconThemeData(
color: isDark
? CupertinoColors.activeBlue.darkColor
: CupertinoColors.activeBlue.color,
size: 20,
);
macosPopupButtonTheme ??= MacosPopupButtonThemeData(
highlightColor: isDark
? CupertinoColors.activeBlue.darkColor
: CupertinoColors.activeBlue.color,
backgroundColor: isDark
? const Color.fromRGBO(255, 255, 255, 0.247)
: const Color.fromRGBO(255, 255, 255, 1),
popupColor: isDark
? const Color.fromRGBO(30, 30, 30, 1)
: const Color.fromRGBO(242, 242, 247, 1),
);
final defaultData = MacosThemeData.raw(
brightness: _brightness,
primaryColor: primaryColor,
canvasColor: canvasColor,
typography: typography,
pushButtonTheme: pushButtonTheme,
dividerColor: dividerColor,
helpButtonTheme: helpButtonTheme,
tooltipTheme: tooltipTheme,
visualDensity: visualDensity,
scrollbarTheme: scrollbarTheme,
macosIconButtonTheme: macosIconButtonThemeData,
iconTheme: iconTheme,
macosPopupButtonTheme: macosPopupButtonTheme,
textFieldTheme: textFieldTheme,
);
final customizedData = defaultData.copyWith(
brightness: _brightness,
primaryColor: primaryColor,
canvasColor: canvasColor,
typography: typography,
pushButtonTheme: pushButtonTheme,
dividerColor: dividerColor,
helpButtonTheme: helpButtonTheme,
tooltipTheme: tooltipTheme,
visualDensity: visualDensity,
scrollbarTheme: scrollbarTheme,
macosIconButtonTheme: macosIconButtonThemeData,
iconTheme: iconTheme,
macosPopupButtonTheme: macosPopupButtonTheme,
);
return defaultData.merge(customizedData);
}