copyWith method
- @useResult
- FAccordionStyle? accordionStyle,
- FAlertStyles? alertStyles,
- FAvatarStyle? avatarStyle,
- FBadgeStyles? badgeStyles,
- FBreadcrumbStyle? breadcrumbStyle,
- FButtonStyles? buttonStyles,
- FCalendarStyle? calendarStyle,
- FCardStyle? cardStyle,
- FCheckboxStyle? checkboxStyle,
- FDateFieldStyle? dateFieldStyle,
- FDialogStyle? dialogStyle,
- FDividerStyles? dividerStyles,
- FHeaderStyles? headerStyles,
- FLabelStyles? labelStyles,
- FLineCalendarStyle? lineCalendarStyle,
- FPaginationStyle? paginationStyle,
- FPickerStyle? pickerStyle,
- FPopoverStyle? popoverStyle,
- FPopoverMenuStyle? popoverMenuStyle,
- FProgressStyles? progressStyles,
- FRadioStyle? radioStyle,
- FResizableStyle? resizableStyle,
- FScaffoldStyle? scaffoldStyle,
- FSelectStyle? selectStyle,
- FSelectGroupStyle? selectGroupStyle,
- FSelectMenuTileStyle? selectMenuTileStyle,
- FSheetStyle? sheetStyle,
- FSidebarStyle? sidebarStyle,
- FSliderStyles? sliderStyles,
- FToasterStyle? toasterStyle,
- FSwitchStyle? switchStyle,
- FTabsStyle? tabsStyle,
- FTappableStyle? tappableStyle,
- FTextFieldStyle? textFieldStyle,
- FTileGroupStyle? tileGroupStyle,
- FTimeFieldStyle? timeFieldStyle,
- FTooltipStyle? tooltipStyle,
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 colors, typography, and/or style, create a new FThemeData
using FThemeData first.
This allows the global theme data to propagate to widget-specific theme data.
@override
Widget build(BuildContext context) {
final theme = FThemeData(
color: FThemes.zinc.light.colors.copyWith(
primary: const Color(0xFF0D47A1), // dark blue
primaryForeground: const Color(0xFFFFFFFF), // white
),
text: 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(...),
);
}
Alternatively, consider using the [CLI](forui.dev/docs/cli).
Implementation
@useResult
FThemeData copyWith({
FAccordionStyle? accordionStyle,
FAlertStyles? alertStyles,
FAvatarStyle? avatarStyle,
FBadgeStyles? badgeStyles,
FBottomNavigationBarStyle? bottomNavigationBarStyle,
FBreadcrumbStyle? breadcrumbStyle,
FButtonStyles? buttonStyles,
FCalendarStyle? calendarStyle,
FCardStyle? cardStyle,
FCheckboxStyle? checkboxStyle,
FDateFieldStyle? dateFieldStyle,
FDialogStyle? dialogStyle,
FDividerStyles? dividerStyles,
FHeaderStyles? headerStyles,
FLabelStyles? labelStyles,
FLineCalendarStyle? lineCalendarStyle,
FPaginationStyle? paginationStyle,
FPickerStyle? pickerStyle,
FPopoverStyle? popoverStyle,
FPopoverMenuStyle? popoverMenuStyle,
FProgressStyles? progressStyles,
FRadioStyle? radioStyle,
FResizableStyle? resizableStyle,
FScaffoldStyle? scaffoldStyle,
FSelectStyle? selectStyle,
FSelectGroupStyle? selectGroupStyle,
FSelectMenuTileStyle? selectMenuTileStyle,
FSheetStyle? sheetStyle,
FSidebarStyle? sidebarStyle,
FSliderStyles? sliderStyles,
FToasterStyle? toasterStyle,
FSwitchStyle? switchStyle,
FTabsStyle? tabsStyle,
FTappableStyle? tappableStyle,
FTextFieldStyle? textFieldStyle,
FTileGroupStyle? tileGroupStyle,
FTimeFieldStyle? timeFieldStyle,
FTooltipStyle? tooltipStyle,
}) => FThemeData(
colors: colors,
typography: typography,
style: style,
accordionStyle: accordionStyle ?? this.accordionStyle,
alertStyles: alertStyles ?? this.alertStyles,
avatarStyle: avatarStyle ?? this.avatarStyle,
badgeStyles: badgeStyles ?? this.badgeStyles,
bottomNavigationBarStyle: bottomNavigationBarStyle ?? this.bottomNavigationBarStyle,
breadcrumbStyle: breadcrumbStyle ?? this.breadcrumbStyle,
buttonStyles: buttonStyles ?? this.buttonStyles,
calendarStyle: calendarStyle ?? this.calendarStyle,
cardStyle: cardStyle ?? this.cardStyle,
checkboxStyle: checkboxStyle ?? this.checkboxStyle,
dateFieldStyle: dateFieldStyle ?? this.dateFieldStyle,
dialogStyle: dialogStyle ?? this.dialogStyle,
dividerStyles: dividerStyles ?? this.dividerStyles,
headerStyles: headerStyles ?? this.headerStyles,
labelStyles: labelStyles ?? this.labelStyles,
lineCalendarStyle: lineCalendarStyle ?? this.lineCalendarStyle,
paginationStyle: paginationStyle ?? this.paginationStyle,
pickerStyle: pickerStyle ?? this.pickerStyle,
popoverStyle: popoverStyle ?? this.popoverStyle,
popoverMenuStyle: popoverMenuStyle ?? this.popoverMenuStyle,
progressStyles: progressStyles ?? this.progressStyles,
radioStyle: radioStyle ?? this.radioStyle,
resizableStyle: resizableStyle ?? this.resizableStyle,
scaffoldStyle: scaffoldStyle ?? this.scaffoldStyle,
selectStyle: selectStyle ?? this.selectStyle,
selectGroupStyle: selectGroupStyle ?? this.selectGroupStyle,
selectMenuTileStyle: selectMenuTileStyle ?? this.selectMenuTileStyle,
sheetStyle: sheetStyle ?? this.sheetStyle,
sidebarStyle: sidebarStyle ?? this.sidebarStyle,
sliderStyles: sliderStyles ?? this.sliderStyles,
toasterStyle: toasterStyle ?? this.toasterStyle,
switchStyle: switchStyle ?? this.switchStyle,
tabsStyle: tabsStyle ?? this.tabsStyle,
tappableStyle: tappableStyle ?? this.tappableStyle,
textFieldStyle: textFieldStyle ?? this.textFieldStyle,
tileGroupStyle: tileGroupStyle ?? this.tileGroupStyle,
timeFieldStyle: timeFieldStyle ?? this.timeFieldStyle,
tooltipStyle: tooltipStyle ?? this.tooltipStyle,
);