copyWith method

  1. @useResult
FThemeData copyWith({
  1. FAccordionStyle? accordionStyle,
  2. FAutocompleteStyle? autocompleteStyle,
  3. FAlertStyles? alertStyles,
  4. FAvatarStyle? avatarStyle,
  5. FBadgeStyles? badgeStyles,
  6. FBottomNavigationBarStyle? bottomNavigationBarStyle,
  7. FBreadcrumbStyle? breadcrumbStyle,
  8. FButtonStyles? buttonStyles,
  9. FCalendarStyle? calendarStyle,
  10. FCardStyle? cardStyle,
  11. FCheckboxStyle? checkboxStyle,
  12. FDateFieldStyle? dateFieldStyle,
  13. FDialogStyle? dialogStyle,
  14. FDividerStyles? dividerStyles,
  15. FHeaderStyles? headerStyles,
  16. FItemStyle? itemStyle,
  17. FItemGroupStyle? itemGroupStyle,
  18. FLabelStyles? labelStyles,
  19. FLineCalendarStyle? lineCalendarStyle,
  20. FMultiSelectStyle? multiSelectStyle,
  21. FPaginationStyle? paginationStyle,
  22. FPickerStyle? pickerStyle,
  23. FPopoverStyle? popoverStyle,
  24. FPopoverMenuStyle? popoverMenuStyle,
  25. FProgressStyles? progressStyles,
  26. FRadioStyle? radioStyle,
  27. FResizableStyle? resizableStyle,
  28. FScaffoldStyle? scaffoldStyle,
  29. FSelectStyle? selectStyle,
  30. FSelectGroupStyle? selectGroupStyle,
  31. FSelectMenuTileStyle? selectMenuTileStyle,
  32. FSheetStyle? sheetStyle,
  33. FSidebarStyle? sidebarStyle,
  34. FSliderStyles? sliderStyles,
  35. FToasterStyle? toasterStyle,
  36. FSwitchStyle? switchStyle,
  37. FTabsStyle? tabsStyle,
  38. FTappableStyle? tappableStyle,
  39. FTextFieldStyle? textFieldStyle,
  40. FTileStyle? tileStyle,
  41. FTileGroupStyle? tileGroupStyle,
  42. FTimeFieldStyle? timeFieldStyle,
  43. FTooltipStyle? tooltipStyle,
  44. 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({
  FAccordionStyle? accordionStyle,
  FAutocompleteStyle? autocompleteStyle,
  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,
  FItemStyle? itemStyle,
  FItemGroupStyle? itemGroupStyle,
  FLabelStyles? labelStyles,
  FLineCalendarStyle? lineCalendarStyle,
  FMultiSelectStyle? multiSelectStyle,
  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,
  FTileStyle? tileStyle,
  FTileGroupStyle? tileGroupStyle,
  FTimeFieldStyle? timeFieldStyle,
  FTooltipStyle? tooltipStyle,
  Iterable<ThemeExtension<dynamic>>? extensions,
}) => FThemeData(
  colors: colors,
  typography: typography,
  style: style,
  accordionStyle: accordionStyle ?? this.accordionStyle,
  autocompleteStyle: autocompleteStyle ?? this.autocompleteStyle,
  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,
  itemStyle: itemStyle ?? this.itemStyle,
  itemGroupStyle: itemGroupStyle ?? this.itemGroupStyle,
  labelStyles: labelStyles ?? this.labelStyles,
  lineCalendarStyle: lineCalendarStyle ?? this.lineCalendarStyle,
  multiSelectStyle: multiSelectStyle ?? this.multiSelectStyle,
  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,
  tileStyle: tileStyle ?? this.tileStyle,
  tileGroupStyle: tileGroupStyle ?? this.tileGroupStyle,
  timeFieldStyle: timeFieldStyle ?? this.timeFieldStyle,
  tooltipStyle: tooltipStyle ?? this.tooltipStyle,
  extensions: extensions ?? this.extensions,
);