ZeroThemeData constructor
ZeroThemeData({
- Brightness? brightness,
- ZeroTypography? typography,
- String? fontFamily,
- bool? useMaterial3,
- AccentColor? primaryColor,
- Color? disabledColor,
- Color? scaffoldBackgroundColor,
- Color? uncheckedColor,
- Color? checkedColor,
- Color? cardColor,
- Color? disabledBackgroundColor,
- Color? successColor,
- Color? infoColor,
- Color? warningColor,
- Color? errorColor,
- Color? dividerColor,
- Color? solidTextColor,
- Color? regularTextColor,
- ColorScheme? colorScheme,
- IconThemeData? iconTheme,
- DialogTheme? dialogTheme,
- ButtonThemeData? buttonTheme,
- InputDecorationTheme? inputDecorationTheme,
- ZeroListTileStyle? listTileStyle,
- ZeroButtonStyle? primaryButtonStyle,
- ZeroButtonStyle? secondaryButtonStyle,
- ZeroButtonStyle? textButtonStyle,
- ZeroDividerStyle? dividerStyle,
- ZeroChipFilledStyle? chipFilledStyle,
- ZeroChipOutlinedStyle? chipOutlinedStyle,
- ZeroTextfieldStyleSet? textfieldStyleSet,
- ZeroAppBarStyle? appBarStyle,
- ZeroCardStyle? cardStyle,
- ZeroButtonIconStyleSet? buttonIconStyle,
- ZeroSwitchStyleSet? switchStyle,
- ZeroTabBarStyle? tabBarStyle,
- ZeroSpeedDialStyle? speedDialStyle,
- ZeroCheckboxStyle? checkboxStyle,
- ZeroRadioStyle? radioStyle,
- ZeroProgressStyle? progressStyle,
- ZeroRatingStyle? ratingStyle,
- ZeroSliderStyle? sliderStyle,
- ZeroAvatarStyle? avatarStyle,
- ZeroButtonGroupStyleSet? buttonGroupStyle,
- ZeroExpansionTileStyle? expansionTileStyle,
- ZeroTooltipStyle? tooltipStyle,
- ZeroSkeletonStyleSet? skeletonStyle,
- ZeroAlertDialogStyle? alertDialogStyle,
- ZeroStepStyle? stepStyle,
- ZeroStepperStyle? stepperStyle,
- ZeroSnackbarStyleSet? snackBarStyle,
- ZeroTimePickerStyle? timePickerStyle,
- ZeroBottomSheetStyle? bottomSheetStyle,
- ZeroDatePickerStyle? datePickerStyle,
Implementation
factory ZeroThemeData({
Brightness? brightness,
ZeroTypography? typography,
String? fontFamily,
bool? useMaterial3,
AccentColor? primaryColor,
Color? disabledColor,
Color? scaffoldBackgroundColor,
Color? uncheckedColor,
Color? checkedColor,
Color? cardColor,
Color? disabledBackgroundColor,
Color? successColor,
Color? infoColor,
Color? warningColor,
Color? errorColor,
Color? dividerColor,
Color? solidTextColor,
Color? regularTextColor,
ColorScheme? colorScheme,
IconThemeData? iconTheme,
DialogTheme? dialogTheme,
ButtonThemeData? buttonTheme,
InputDecorationTheme? inputDecorationTheme,
ZeroListTileStyle? listTileStyle,
ZeroButtonStyle? primaryButtonStyle,
ZeroButtonStyle? secondaryButtonStyle,
ZeroButtonStyle? textButtonStyle,
ZeroDividerStyle? dividerStyle,
ZeroChipFilledStyle? chipFilledStyle,
ZeroChipOutlinedStyle? chipOutlinedStyle,
ZeroNavigationBarStyle? navigationBarStyle,
ZeroTextfieldStyleSet? textfieldStyleSet,
ZeroNavigationDrawerStyle? navigationDrawerStyle,
ZeroAppBarStyle? appBarStyle,
ZeroCardStyle? cardStyle,
ZeroButtonIconStyleSet? buttonIconStyle,
ZeroNavigationRailStyle? navigationRailStyle,
ZeroSwitchStyleSet? switchStyle,
ZeroTabBarStyle? tabBarStyle,
ZeroSpeedDialStyle? speedDialStyle,
ZeroCheckboxStyle? checkboxStyle,
ZeroRadioStyle? radioStyle,
ZeroProgressStyle? progressStyle,
ZeroRatingStyle? ratingStyle,
ZeroSliderStyle? sliderStyle,
ZeroAvatarStyle? avatarStyle,
ZeroButtonGroupStyleSet? buttonGroupStyle,
ZeroExpansionTileStyle? expansionTileStyle,
ZeroMenuStyle? menuStyle,
ZeroTooltipStyle? tooltipStyle,
ZeroSkeletonStyleSet? skeletonStyle,
ZeroAlertDialogStyle? alertDialogStyle,
ZeroStepStyle? stepStyle,
ZeroStepperStyle? stepperStyle,
ZeroSnackbarStyleSet? snackBarStyle,
ZeroTimePickerStyle? timePickerStyle,
ZeroBottomSheetStyle? bottomSheetStyle,
ZeroDatePickerStyle? datePickerStyle,
}) {
// TODO: Finalize the default style of theme
brightness ??= Brightness.light;
final isLight = brightness.isLight;
// Base Colors
primaryColor ??= ZeroColors.primary.toAccentColor();
disabledColor ??= isLight ? ZeroColors.neutral[7] : ZeroColors.neutral[6];
disabledBackgroundColor ??=
isLight ? ZeroColors.neutral[3] : ZeroColors.neutral[8];
scaffoldBackgroundColor ??=
isLight ? ZeroColors.neutral[2] : ZeroColors.neutral[11];
uncheckedColor ??= isLight ? ZeroColors.neutral[7] : ZeroColors.neutral[4];
checkedColor ??= primaryColor;
cardColor ??= isLight ? ZeroColors.white : ZeroColors.neutral[9];
successColor ??= ZeroColors.success;
infoColor ??= ZeroColors.info;
warningColor ??= ZeroColors.warning;
errorColor ??= ZeroColors.danger;
dividerColor ??= isLight ? ZeroColors.neutral[5] : ZeroColors.neutral[6];
solidTextColor ??= isLight ? ZeroColors.neutral[10] : ZeroColors.neutral[5];
regularTextColor ??=
isLight ? ZeroColors.neutral[7] : ZeroColors.neutral[6];
typography ??= ZeroTypography.fromBrightness(
color: solidTextColor,
fontFamily: fontFamily,
).merge(typography);
iconTheme ??= isLight
? const IconThemeData(color: ZeroColors.black, size: 24.0)
: const IconThemeData(color: ZeroColors.white, size: 24.0);
dialogTheme ??= isLight
? DialogTheme(
backgroundColor: ZeroColors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
titleTextStyle: typography.heading6,
contentTextStyle: typography.body2,
)
: DialogTheme(
backgroundColor: ZeroColors.neutral[10],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
titleTextStyle: typography.heading6,
contentTextStyle: typography.body2,
);
buttonTheme ??= const ButtonThemeData(
alignedDropdown: true,
);
final expansionTileStyleFallback = ZeroExpansionTileStyle.fallback(
backgroundColor: scaffoldBackgroundColor,
collapsedBackgroundColor: scaffoldBackgroundColor,
childrenBackgroundColor: scaffoldBackgroundColor,
iconColor: typography.subtitle1?.color ?? ZeroColors.neutral[10],
collapsedIconColor:
typography.subtitle1?.color ?? ZeroColors.neutral[10],
titleColor: ZeroColors.neutral[5],
collapsedTitleColor: ZeroColors.neutral[3],
textColor: typography.subtitle1?.color ?? ZeroColors.neutral[10],
collapsedTextColor:
typography.subtitle1?.color ?? ZeroColors.neutral[10]);
final textfieldStyleSetFallBack = ZeroTextfieldStyleSet.fallback(
defaultDecorationType: InputDecorationType.outline,
outline: ZeroTextfieldStyle.outline(
textfieldSize: ZeroTextfieldSize.small,
focusedBorderColor: primaryColor,
focusedColor: primaryColor),
rounded: ZeroTextfieldStyle.rounded(
textfieldSize: ZeroTextfieldSize.small,
focusedBorderColor: primaryColor,
focusedColor: primaryColor),
filled: ZeroTextfieldStyle.fill(
textfieldSize: ZeroTextfieldSize.small,
focusedBorderColor: primaryColor,
focusedColor: primaryColor,
fillColor: primaryColor.lightest),
underline: ZeroTextfieldStyle.underline(
textfieldSize: ZeroTextfieldSize.small,
focusedBorderColor: primaryColor,
focusedColor: primaryColor),
focusedBorderColor: primaryColor,
focusedColor: primaryColor,
textfieldSize: ZeroTextfieldSize.small);
skeletonStyle ??= const ZeroSkeletonStyleSet(
avatar: SkeletonAvatarStyle(),
line: SkeletonLineStyle(),
listTile: SkeletonListTileStyle(),
paragraph: SkeletonParagraphStyle(),
);
colorScheme ??= ColorScheme.fromSwatch(
brightness: brightness,
cardColor: cardColor,
errorColor: errorColor,
backgroundColor: scaffoldBackgroundColor,
primarySwatch: MaterialColor(
primaryColor.value,
{
50: primaryColor.lightest,
100: primaryColor.lightest,
200: primaryColor.lighter,
300: primaryColor.lighter,
400: primaryColor.light,
500: primaryColor.normal,
600: primaryColor.dark,
700: primaryColor.darker,
800: primaryColor.darker,
900: primaryColor.darkest,
},
),
).copyWith(
error: errorColor,
onPrimary: Colors.white,
);
// Component Styles
final listTileFallback = ZeroListTileStyle.fallback(
dividerColor: dividerColor,
selectedColor: primaryColor.lightest,
titleStyle: typography.subtitle1?.copyWith(color: solidTextColor),
subTitleStyle: typography.subtitle2?.copyWith(color: regularTextColor),
smallTitleStyle: typography.subtitle1?.copyWith(color: solidTextColor),
smallSubTitleStyle:
typography.subtitle2?.copyWith(color: regularTextColor),
);
final primaryButtonStyleFallback = ZeroButtonStyle.primaryStyle(
backgroundColor: primaryColor,
foregroundColor: Colors.white,
surfaceTintColor: primaryColor.lighter,
animatingColor: primaryColor.lighter,
textStyle: typography.button?.copyWith(color: ZeroColors.white),
disabledForegroundColor: disabledColor,
disabledBackgroundColor: disabledBackgroundColor,
);
final secondaryButtonStyleFallback = ZeroButtonStyle.secondaryStyle(
backgroundColor: Colors.transparent,
foregroundColor: solidTextColor,
surfaceTintColor: primaryColor.lighter,
animatingColor: primaryColor.lighter,
textStyle: typography.button?.copyWith(color: solidTextColor),
disabledForegroundColor: disabledColor,
disabledBackgroundColor: disabledBackgroundColor,
side: BorderSide(color: dividerColor),
);
final textButtonStyleFallback = secondaryButtonStyleFallback.copyWith(
elevation: 0,
side: BorderSide.none,
foregroundColor: solidTextColor,
disabledForegroundColor: disabledColor,
disabledBackgroundColor: ZeroColors.transparent,
);
final dividerStyleFallback = ZeroDividerStyle.fallback(color: dividerColor);
final chipFilledStyleFallback = ZeroChipFilledStyle.fallback(
textStyle: TextStyle(color: solidTextColor),
backgroundColor: isLight ? ZeroColors.neutral[4] : ZeroColors.neutral[8],
);
final chipOutlinedStyleFallback = ZeroChipOutlinedStyle.fallback(
textStyle: TextStyle(color: solidTextColor),
);
final navigationBarStyleFallback = ZeroNavigationBarStyle.fallback(
backgroundColor: isLight ? ZeroColors.white : ZeroColors.black,
indicatorColor: primaryColor.lighter,
selectedColor: isLight ? ZeroColors.black : ZeroColors.white,
unselectedColor: isLight ? ZeroColors.black : ZeroColors.white,
);
final navigationDrawerStyleFallback = ZeroNavigationDrawerStyle.fallback(
backgroundColor: isLight ? ZeroColors.white : ZeroColors.black,
headerTitleStyle: typography.subtitle1,
sectionTitleStyle: typography.subtitle2,
);
final cardStyle = ZeroCardStyle.fallback(
backgroundColor: cardColor,
side: BorderSide(color: dividerColor, width: 1),
);
final appBarStyleFallback = ZeroAppBarStyle.fallback(
backgroundColor: isLight ? ZeroColors.white : ZeroColors.black,
foregroundColor: isLight ? ZeroColors.neutral[10] : ZeroColors.neutral[4],
statusBarBrightness: isLight ? Brightness.light : Brightness.dark,
titleStyle: typography.heading5,
);
final buttonIconStyleFallback = ZeroButtonIconStyleSet.fallback(
primaryColor: primaryColor,
disabledColor: disabledColor,
);
final navigationRailStyleFallback = ZeroNavigationRailStyle.fallback(
backgrondColor: isLight ? ZeroColors.white : ZeroColors.black,
activeColor: isLight ? ZeroColors.white : ZeroColors.black,
inactiveColor: isLight ? ZeroColors.neutral[12] : ZeroColors.neutral[3],
indicatorColor: primaryColor,
labelStyle: typography.caption,
);
final switchStyleFallback = ZeroSwitchStyleSet.fallback(
primaryColor: primaryColor,
inActiveColor: disabledColor,
inActiveIOSColor: dividerColor,
disabledColor: dividerColor,
);
final tabBarStyleFallback = ZeroTabBarStyle.fallback(
activeColor: primaryColor,
indicatorColor: primaryColor,
inactiveColor: regularTextColor,
);
final checkboxStyleFallback = ZeroCheckboxStyle.fallback(
activeColor: checkedColor,
checkColor: colorScheme.onPrimary,
inactiveColor: uncheckedColor,
disabledColor: disabledColor,
);
final radioStyleFallback = ZeroRadioStyle.fallback(
activeColor: checkedColor,
inactiveColor: uncheckedColor,
disabledColor: disabledColor,
);
final progeressStyleFallback = ZeroProgressStyle.fallback(
backgroundColor: isLight ? ZeroColors.neutral[4] : ZeroColors.neutral[10],
lineSize: 4,
valueColor: primaryColor,
);
final ratingStyleFallback = ZeroRatingStyle.fallback(
inactiveColor: isLight ? ZeroColors.neutral : ZeroColors.neutral[10],
spacing: 2,
);
final sliderStyleFallback = ZeroSliderStyle.fallback(
primaryColor: primaryColor,
thickColor: primaryColor,
);
final avatarStyleFallback =
ZeroAvatarStyle.fallback(backgroundColor: primaryColor);
final menuStyleFallback = ZeroMenuStyle.fallback();
final buttonGroupStyleFallback = ZeroButtonGroupStyleSet.fallback(
primaryColor: primaryColor,
textColor: solidTextColor,
textActiveBackgroundColor: disabledBackgroundColor,
);
final tooltipStyleFallback = ZeroTooltipStyle.fallback(
borderColor: dividerColor,
darkColor: ZeroColors.neutral[10],
lightColor: ZeroColors.neutral[2],
);
final speedDialStyleFallback = ZeroSpeedDialStyle.fallback(
activeColor: isLight ? ZeroColors.white : ZeroColors.black,
inactiveColor: isLight ? ZeroColors.white : ZeroColors.black,
tooltipStyle: tooltipStyleFallback.merge(tooltipStyle),
);
final alertDialogFallback = ZeroAlertDialogStyle.fallback(
backgroundColor: isLight ? ZeroColors.white : ZeroColors.neutral[10],
titleTextStyle: typography.heading6,
contentTextStyle: typography.body2,
barrierColor: ZeroColors.black.withOpacity(0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
);
final stepStyleFallback = ZeroStepStyle.fallback(
activeColor: primaryColor,
inactiveColor: isLight ? ZeroColors.neutral[7] : ZeroColors.neutral[9],
errorColor: errorColor,
iconColor: ZeroColors.white,
indexTextStyle: typography.body2?.copyWith(color: ZeroColors.white),
titleTextStyle: typography.body1,
subtitleTextStyle: typography.subtitle2,
contentTextStyle: typography.body1,
labelTextStyle: typography.body2,
);
final stepperStyleFallback = ZeroStepperStyle.fallback(
dividerColor: dividerColor,
elevation: 0,
margin: const EdgeInsetsDirectional.only(
start: 60.0,
end: 24.0,
bottom: 24.0,
),
);
final snackBarStyleFallback = ZeroSnackbarStyleSet.fallback(
textStyle: typography.body2,
titleStyle: typography.subtitle1,
snackbarBackgroundColor: cardColor,
defaultDangerColor: errorColor,
defaultInfoColor: infoColor,
defaultSuccessColor: successColor,
defaultWarningColor: warningColor,
);
final timePickerStyleFallback = ZeroTimePickerStyle.fallback(
hourMinute: const HourMinuteControlStyle(),
textfieldStyle: ZeroTextfieldStyle.outline(
focusedBorderColor: colorScheme.primary,
focusedColor: colorScheme.primary.withOpacity(isLight ? 0.12 : 0.24),
),
);
final bottomSheetStyleFallback = ZeroBottomSheetStyle.fallback(
handleColor: dividerColor,
backgroundColor: cardColor,
);
final datePickerStyleFallback = ZeroDatePickerStyle.fallback(
textfieldStyle: ZeroTextfieldStyle.outline(
focusedBorderColor: colorScheme.primary,
focusedColor: colorScheme.primary),
headerBackgroundColor: scaffoldBackgroundColor,
pickerBackgroundColor: scaffoldBackgroundColor,
shape: const RoundedRectangleBorder(),
elevation: 0,
);
useMaterial3 ??= false;
return ZeroThemeData.raw(
brightness: brightness,
useMaterial3: useMaterial3,
primaryColor: primaryColor,
disabledColor: disabledColor,
scaffoldBackgroundColor: scaffoldBackgroundColor,
uncheckedColor: uncheckedColor,
checkedColor: checkedColor,
successColor: successColor,
infoColor: infoColor,
warningColor: warningColor,
iconTheme: iconTheme,
dialogTheme: dialogTheme,
buttonTheme: buttonTheme,
expansionTileStyle: expansionTileStyleFallback.merge(expansionTileStyle),
colorScheme: colorScheme,
typography: typography,
cardColor: cardColor,
errorColor: errorColor,
disabledBackgroundColor: disabledBackgroundColor,
dividerColor: dividerColor,
solidTextColor: solidTextColor,
regularTextColor: regularTextColor,
fontFamily: fontFamily,
listTileStyle: listTileFallback.merge(listTileStyle),
primaryButtonStyle: primaryButtonStyleFallback.merge(primaryButtonStyle),
secondaryButtonStyle:
secondaryButtonStyleFallback.merge(secondaryButtonStyle),
textButtonStyle: textButtonStyleFallback.merge(textButtonStyle),
dividerStyle: dividerStyleFallback.merge(dividerStyle),
chipFilledStyle: chipFilledStyleFallback.merge(chipFilledStyle),
chipOutlinedStyle: chipOutlinedStyleFallback.merge(chipOutlinedStyle),
navigationBarStyle: navigationBarStyleFallback.merge(navigationBarStyle),
textfieldStyleSet: textfieldStyleSetFallBack.merge(textfieldStyleSet),
navigationDrawerStyle:
navigationDrawerStyleFallback.merge(navigationDrawerStyle),
appBarStyle: appBarStyleFallback.merge(appBarStyle),
cardStyle: cardStyle.merge(cardStyle),
buttonIconStyle: buttonIconStyleFallback.merge(buttonIconStyle),
navigationRailStyle:
navigationRailStyleFallback.merge(navigationRailStyle),
switchStyle: switchStyleFallback.merge(switchStyle),
tabBarStyle: tabBarStyleFallback.merge(tabBarStyle),
speedDialStyle: speedDialStyleFallback.merge(speedDialStyle),
checkboxStyle: checkboxStyleFallback.merge(checkboxStyle),
radioStyle: radioStyleFallback.merge(radioStyle),
progressStyle: progeressStyleFallback.merge(progressStyle),
ratingStyle: ratingStyleFallback.merge(ratingStyle),
sliderStyle: sliderStyleFallback.merge(sliderStyle),
avatarStyle: avatarStyleFallback.merge(avatarStyle),
buttonGroupStyle: buttonGroupStyleFallback.merge(buttonGroupStyle),
tooltipStyle: tooltipStyleFallback.merge(tooltipStyle),
menuStyle: menuStyleFallback.merge(menuStyle),
skeletonStyle: skeletonStyle,
alertDialogStyle: alertDialogFallback.merge(alertDialogStyle),
stepStyle: stepStyleFallback.merge(stepStyle),
stepperStyle: stepperStyleFallback.merge(stepperStyle),
snackBarStyle: snackBarStyleFallback.merge(snackBarStyle),
timePickerStyle: timePickerStyleFallback.merge(timePickerStyle),
bottomSheetStyle: bottomSheetStyleFallback.merge(bottomSheetStyle),
datePickerStyle: datePickerStyleFallback.merge(datePickerStyleFallback),
);
}