copyWith method
- @useResult
- String? debugLabel,
- FBreakpoints? breakpoints,
- FColors? colors,
- FTypography? typography,
- FStyle style(
- FStyle style
- FAccordionStyle accordionStyle(
- FAccordionStyle style
- FAutocompleteStyle autocompleteStyle(
- FAutocompleteStyle style
- FAlertStyles alertStyles(
- FAlertStyles style
- FAvatarStyle avatarStyle(
- FAvatarStyle style
- FBadgeStyles badgeStyles(
- FBadgeStyles style
- FBreadcrumbStyle breadcrumbStyle(
- FBreadcrumbStyle style
- FButtonStyles buttonStyles(
- FButtonStyles style
- FCalendarStyle calendarStyle(
- FCalendarStyle style
- FCardStyle cardStyle(
- FCardStyle style
- FCheckboxStyle checkboxStyle(
- FCheckboxStyle style
- FCircularProgressStyle circularProgressStyle(
- FCircularProgressStyle style
- FDateFieldStyle dateFieldStyle(
- FDateFieldStyle style
- FDeterminateProgressStyle determinateProgressStyle()?,
- FDialogRouteStyle dialogRouteStyle(
- FDialogRouteStyle style
- FDialogStyle dialogStyle(
- FDialogStyle style
- FDividerStyles dividerStyles(
- FDividerStyles style
- FHeaderStyles headerStyles(
- FHeaderStyles style
- FItemStyle itemStyle(
- FItemStyle style
- FItemGroupStyle itemGroupStyle(
- FItemGroupStyle style
- FLabelStyles labelStyles(
- FLabelStyles style
- FLineCalendarStyle lineCalendarStyle(
- FLineCalendarStyle style
- FMultiSelectStyle multiSelectStyle(
- FMultiSelectStyle style
- FModalSheetStyle modalSheetStyle(
- FModalSheetStyle style
- FPaginationStyle paginationStyle(
- FPaginationStyle style
- FPersistentSheetStyle persistentSheetStyle(
- FPersistentSheetStyle style
- FPickerStyle pickerStyle(
- FPickerStyle style
- FPopoverStyle popoverStyle(
- FPopoverStyle style
- FPopoverMenuStyle popoverMenuStyle(
- FPopoverMenuStyle style
- FProgressStyle progressStyle(
- FProgressStyle style
- FRadioStyle radioStyle(
- FRadioStyle style
- FResizableStyle resizableStyle(
- FResizableStyle style
- FScaffoldStyle scaffoldStyle(
- FScaffoldStyle style
- FSelectStyle selectStyle(
- FSelectStyle style
- FSelectGroupStyle selectGroupStyle(
- FSelectGroupStyle style
- FSelectMenuTileStyle selectMenuTileStyle(
- FSelectMenuTileStyle style
- FSidebarStyle sidebarStyle(
- FSidebarStyle style
- FSliderStyles sliderStyles(
- FSliderStyles style
- FToasterStyle toasterStyle(
- FToasterStyle style
- FSwitchStyle switchStyle(
- FSwitchStyle style
- FTabsStyle tabsStyle(
- FTabsStyle style
- FTappableStyle tappableStyle(
- FTappableStyle style
- FTextFieldStyle textFieldStyle(
- FTextFieldStyle style
- FTileStyle tileStyle(
- FTileStyle style
- FTileGroupStyle tileGroupStyle(
- FTileGroupStyle style
- FTimeFieldStyle timeFieldStyle(
- FTimeFieldStyle style
- FTimePickerStyle timePickerStyle(
- FTimePickerStyle style
- FTooltipStyle tooltipStyle(
- FTooltipStyle style
- Iterable<
ThemeExtension> ? extensions,
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({
String? debugLabel,
FBreakpoints? breakpoints,
FColors? colors,
FTypography? typography,
FStyle Function(FStyle style)? style,
FAccordionStyle Function(FAccordionStyle style)? accordionStyle,
FAutocompleteStyle Function(FAutocompleteStyle style)? autocompleteStyle,
FAlertStyles Function(FAlertStyles style)? alertStyles,
FAvatarStyle Function(FAvatarStyle style)? avatarStyle,
FBadgeStyles Function(FBadgeStyles style)? badgeStyles,
FBottomNavigationBarStyle Function(FBottomNavigationBarStyle style)? bottomNavigationBarStyle,
FBreadcrumbStyle Function(FBreadcrumbStyle style)? breadcrumbStyle,
FButtonStyles Function(FButtonStyles style)? buttonStyles,
FCalendarStyle Function(FCalendarStyle style)? calendarStyle,
FCardStyle Function(FCardStyle style)? cardStyle,
FCheckboxStyle Function(FCheckboxStyle style)? checkboxStyle,
FCircularProgressStyle Function(FCircularProgressStyle style)? circularProgressStyle,
FDateFieldStyle Function(FDateFieldStyle style)? dateFieldStyle,
FDeterminateProgressStyle Function(FDeterminateProgressStyle style)? determinateProgressStyle,
FDialogRouteStyle Function(FDialogRouteStyle style)? dialogRouteStyle,
FDialogStyle Function(FDialogStyle style)? dialogStyle,
FDividerStyles Function(FDividerStyles style)? dividerStyles,
FHeaderStyles Function(FHeaderStyles style)? headerStyles,
FItemStyle Function(FItemStyle style)? itemStyle,
FItemGroupStyle Function(FItemGroupStyle style)? itemGroupStyle,
FLabelStyles Function(FLabelStyles style)? labelStyles,
FLineCalendarStyle Function(FLineCalendarStyle style)? lineCalendarStyle,
FMultiSelectStyle Function(FMultiSelectStyle style)? multiSelectStyle,
FModalSheetStyle Function(FModalSheetStyle style)? modalSheetStyle,
FPaginationStyle Function(FPaginationStyle style)? paginationStyle,
FPersistentSheetStyle Function(FPersistentSheetStyle style)? persistentSheetStyle,
FPickerStyle Function(FPickerStyle style)? pickerStyle,
FPopoverStyle Function(FPopoverStyle style)? popoverStyle,
FPopoverMenuStyle Function(FPopoverMenuStyle style)? popoverMenuStyle,
FProgressStyle Function(FProgressStyle style)? progressStyle,
FRadioStyle Function(FRadioStyle style)? radioStyle,
FResizableStyle Function(FResizableStyle style)? resizableStyle,
FScaffoldStyle Function(FScaffoldStyle style)? scaffoldStyle,
FSelectStyle Function(FSelectStyle style)? selectStyle,
FSelectGroupStyle Function(FSelectGroupStyle style)? selectGroupStyle,
FSelectMenuTileStyle Function(FSelectMenuTileStyle style)? selectMenuTileStyle,
FSidebarStyle Function(FSidebarStyle style)? sidebarStyle,
FSliderStyles Function(FSliderStyles style)? sliderStyles,
FToasterStyle Function(FToasterStyle style)? toasterStyle,
FSwitchStyle Function(FSwitchStyle style)? switchStyle,
FTabsStyle Function(FTabsStyle style)? tabsStyle,
FTappableStyle Function(FTappableStyle style)? tappableStyle,
FTextFieldStyle Function(FTextFieldStyle style)? textFieldStyle,
FTileStyle Function(FTileStyle style)? tileStyle,
FTileGroupStyle Function(FTileGroupStyle style)? tileGroupStyle,
FTimeFieldStyle Function(FTimeFieldStyle style)? timeFieldStyle,
FTimePickerStyle Function(FTimePickerStyle style)? timePickerStyle,
FTooltipStyle Function(FTooltipStyle style)? tooltipStyle,
Iterable<ThemeExtension<dynamic>>? extensions,
}) => FThemeData(
debugLabel: debugLabel ?? this.debugLabel,
breakpoints: breakpoints ?? this.breakpoints,
colors: colors ?? this.colors,
typography: typography ?? this.typography,
style: style != null ? style(this.style) : this.style,
accordionStyle: accordionStyle != null ? accordionStyle(this.accordionStyle) : this.accordionStyle,
autocompleteStyle: autocompleteStyle != null ? autocompleteStyle(this.autocompleteStyle) : this.autocompleteStyle,
alertStyles: alertStyles != null ? alertStyles(this.alertStyles) : this.alertStyles,
avatarStyle: avatarStyle != null ? avatarStyle(this.avatarStyle) : this.avatarStyle,
badgeStyles: badgeStyles != null ? badgeStyles(this.badgeStyles) : this.badgeStyles,
bottomNavigationBarStyle: bottomNavigationBarStyle != null
? bottomNavigationBarStyle(this.bottomNavigationBarStyle)
: this.bottomNavigationBarStyle,
breadcrumbStyle: breadcrumbStyle != null ? breadcrumbStyle(this.breadcrumbStyle) : this.breadcrumbStyle,
buttonStyles: buttonStyles != null ? buttonStyles(this.buttonStyles) : this.buttonStyles,
calendarStyle: calendarStyle != null ? calendarStyle(this.calendarStyle) : this.calendarStyle,
cardStyle: cardStyle != null ? cardStyle(this.cardStyle) : this.cardStyle,
checkboxStyle: checkboxStyle != null ? checkboxStyle(this.checkboxStyle) : this.checkboxStyle,
circularProgressStyle: circularProgressStyle != null
? circularProgressStyle(this.circularProgressStyle)
: this.circularProgressStyle,
dateFieldStyle: dateFieldStyle != null ? dateFieldStyle(this.dateFieldStyle) : this.dateFieldStyle,
determinateProgressStyle: determinateProgressStyle != null
? determinateProgressStyle(this.determinateProgressStyle)
: this.determinateProgressStyle,
dialogRouteStyle: dialogRouteStyle != null ? dialogRouteStyle(this.dialogRouteStyle) : this.dialogRouteStyle,
dialogStyle: dialogStyle != null ? dialogStyle(this.dialogStyle) : this.dialogStyle,
dividerStyles: dividerStyles != null ? dividerStyles(this.dividerStyles) : this.dividerStyles,
headerStyles: headerStyles != null ? headerStyles(this.headerStyles) : this.headerStyles,
itemStyle: itemStyle != null ? itemStyle(this.itemStyle) : this.itemStyle,
itemGroupStyle: itemGroupStyle != null ? itemGroupStyle(this.itemGroupStyle) : this.itemGroupStyle,
labelStyles: labelStyles != null ? labelStyles(this.labelStyles) : this.labelStyles,
lineCalendarStyle: lineCalendarStyle != null ? lineCalendarStyle(this.lineCalendarStyle) : this.lineCalendarStyle,
multiSelectStyle: multiSelectStyle != null ? multiSelectStyle(this.multiSelectStyle) : this.multiSelectStyle,
modalSheetStyle: modalSheetStyle != null ? modalSheetStyle(this.modalSheetStyle) : this.modalSheetStyle,
paginationStyle: paginationStyle != null ? paginationStyle(this.paginationStyle) : this.paginationStyle,
persistentSheetStyle: persistentSheetStyle != null
? persistentSheetStyle(this.persistentSheetStyle)
: this.persistentSheetStyle,
pickerStyle: pickerStyle != null ? pickerStyle(this.pickerStyle) : this.pickerStyle,
popoverStyle: popoverStyle != null ? popoverStyle(this.popoverStyle) : this.popoverStyle,
popoverMenuStyle: popoverMenuStyle != null ? popoverMenuStyle(this.popoverMenuStyle) : this.popoverMenuStyle,
progressStyle: progressStyle != null ? progressStyle(this.progressStyle) : this.progressStyle,
radioStyle: radioStyle != null ? radioStyle(this.radioStyle) : this.radioStyle,
resizableStyle: resizableStyle != null ? resizableStyle(this.resizableStyle) : this.resizableStyle,
scaffoldStyle: scaffoldStyle != null ? scaffoldStyle(this.scaffoldStyle) : this.scaffoldStyle,
selectStyle: selectStyle != null ? selectStyle(this.selectStyle) : this.selectStyle,
selectGroupStyle: selectGroupStyle != null ? selectGroupStyle(this.selectGroupStyle) : this.selectGroupStyle,
selectMenuTileStyle: selectMenuTileStyle != null
? selectMenuTileStyle(this.selectMenuTileStyle)
: this.selectMenuTileStyle,
sidebarStyle: sidebarStyle != null ? sidebarStyle(this.sidebarStyle) : this.sidebarStyle,
sliderStyles: sliderStyles != null ? sliderStyles(this.sliderStyles) : this.sliderStyles,
toasterStyle: toasterStyle != null ? toasterStyle(this.toasterStyle) : this.toasterStyle,
switchStyle: switchStyle != null ? switchStyle(this.switchStyle) : this.switchStyle,
tabsStyle: tabsStyle != null ? tabsStyle(this.tabsStyle) : this.tabsStyle,
tappableStyle: tappableStyle != null ? tappableStyle(this.tappableStyle) : this.tappableStyle,
textFieldStyle: textFieldStyle != null ? textFieldStyle(this.textFieldStyle) : this.textFieldStyle,
tileStyle: tileStyle != null ? tileStyle(this.tileStyle) : this.tileStyle,
tileGroupStyle: tileGroupStyle != null ? tileGroupStyle(this.tileGroupStyle) : this.tileGroupStyle,
timeFieldStyle: timeFieldStyle != null ? timeFieldStyle(this.timeFieldStyle) : this.timeFieldStyle,
timePickerStyle: timePickerStyle != null ? timePickerStyle(this.timePickerStyle) : this.timePickerStyle,
tooltipStyle: tooltipStyle != null ? tooltipStyle(this.tooltipStyle) : this.tooltipStyle,
extensions: extensions ?? this.extensions,
);