copyWith method
- @useResult
- FAccordionStyle? accordionStyle,
- FAlertStyles? alertStyles,
- FAvatarStyle? avatarStyle,
- FBadgeStyles? badgeStyles,
- FButtonStyles? buttonStyles,
- FCalendarStyle? calendarStyle,
- FCardStyle? cardStyle,
- FCheckboxStyle? checkboxStyle,
- FDialogStyle? dialogStyle,
- FDividerStyles? dividerStyles,
- FHeaderStyles? headerStyle,
- FLabelStyles? labelStyles,
- FPopoverStyle? popoverStyle,
- FProgressStyle? progressStyle,
- FRadioStyle? radioStyle,
- FResizableStyle? resizableStyle,
- FTabsStyle? tabsStyle,
- FTextFieldStyle? textFieldStyle,
- FTooltipStyle? tooltipStyle,
- FScaffoldStyle? scaffoldStyle,
- FSelectGroupStyle? selectGroupStyle,
- FSliderStyles? sliderStyles,
- FSwitchStyle? switchStyle,
Returns a copy of this FThemeData with the given properties replaced.
final theme = FThemeData(
alertStyles: ...,
avatarStyle: ...,
);
final copy = theme.copyWith(avatarStyle: bar);
print(theme.alertStyles == copy.alertStyles); // true
print(theme.avatarStyle == copy.avatarStyle); // false
To modify colorScheme, typography, and/or style, create a new FThemeData
using FThemeData.inherit first.
This allows the global theme data to propagate to widget-specific theme data.
@override
Widget build(BuildContext context) {
final theme = FThemeData.inherit(
colorScheme: FThemes.zinc.light.colorScheme.copyWith(
primary: const Color(0xFF0D47A1), // dark blue
primaryForeground: const Color(0xFFFFFFFF), // white
),
typography: FThemes.zinc.light.typography.copyWith(
defaultFontFamily: 'Roboto',
).scale(sizeScalar: 0.8),
style: FThemes.zinc.light.style.copyWith(
borderRadius: BorderRadius.zero,
),
);
return FTheme(
data: theme.copyWith(
cardStyle: theme.cardStyle.copyWith(
decoration: theme.cardStyle.decoration.copyWith(
borderRadius: const BorderRadius.all(Radius.circular(8)),
),
),
),
child: const FScaffold(...),
);
}
Implementation
@useResult
FThemeData copyWith({
FAccordionStyle? accordionStyle,
FAlertStyles? alertStyles,
FAvatarStyle? avatarStyle,
FBadgeStyles? badgeStyles,
FBottomNavigationBarStyle? bottomNavigationBarStyle,
FButtonStyles? buttonStyles,
FCalendarStyle? calendarStyle,
FCardStyle? cardStyle,
FCheckboxStyle? checkboxStyle,
FDialogStyle? dialogStyle,
FDividerStyles? dividerStyles,
FHeaderStyles? headerStyle,
FLabelStyles? labelStyles,
FPopoverStyle? popoverStyle,
FProgressStyle? progressStyle,
FRadioStyle? radioStyle,
FResizableStyle? resizableStyle,
FTabsStyle? tabsStyle,
FTextFieldStyle? textFieldStyle,
FTooltipStyle? tooltipStyle,
FScaffoldStyle? scaffoldStyle,
FSelectGroupStyle? selectGroupStyle,
FSliderStyles? sliderStyles,
FSwitchStyle? switchStyle,
}) =>
FThemeData(
colorScheme: colorScheme,
typography: typography,
style: style,
accordionStyle: accordionStyle ?? this.accordionStyle,
alertStyles: alertStyles ?? this.alertStyles,
avatarStyle: avatarStyle ?? this.avatarStyle,
badgeStyles: badgeStyles ?? this.badgeStyles,
bottomNavigationBarStyle: bottomNavigationBarStyle ?? this.bottomNavigationBarStyle,
buttonStyles: buttonStyles ?? this.buttonStyles,
calendarStyle: calendarStyle ?? this.calendarStyle,
cardStyle: cardStyle ?? this.cardStyle,
checkboxStyle: checkboxStyle ?? this.checkboxStyle,
dialogStyle: dialogStyle ?? this.dialogStyle,
dividerStyles: dividerStyles ?? this.dividerStyles,
headerStyle: headerStyle ?? this.headerStyle,
labelStyles: labelStyles ?? this.labelStyles,
popoverStyle: popoverStyle ?? this.popoverStyle,
progressStyle: progressStyle ?? this.progressStyle,
radioStyle: radioStyle ?? this.radioStyle,
resizableStyle: resizableStyle ?? this.resizableStyle,
tabsStyle: tabsStyle ?? this.tabsStyle,
textFieldStyle: textFieldStyle ?? this.textFieldStyle,
tooltipStyle: tooltipStyle ?? this.tooltipStyle,
scaffoldStyle: scaffoldStyle ?? this.scaffoldStyle,
selectGroupStyle: selectGroupStyle ?? this.selectGroupStyle,
sliderStyles: sliderStyles ?? this.sliderStyles,
switchStyle: switchStyle ?? this.switchStyle,
);