copyWith method
- {bool? applyElevationOverlayColor,
- NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
- Iterable<
ThemeExtension> ? extensions, - InputDecorationTheme? inputDecorationTheme,
- MaterialTapTargetSize? materialTapTargetSize,
- PageTransitionsTheme? pageTransitionsTheme,
- TargetPlatform? platform,
- ScrollbarThemeData? scrollbarTheme,
- InteractiveInkFeatureFactory? splashFactory,
- bool? useMaterial3,
- VisualDensity? visualDensity,
- Brightness? brightness,
- Color? canvasColor,
- Color? cardColor,
- ColorScheme? colorScheme,
- Color? dialogBackgroundColor,
- Color? disabledColor,
- Color? dividerColor,
- Color? focusColor,
- Color? highlightColor,
- Color? hintColor,
- Color? hoverColor,
- Color? indicatorColor,
- Color? primaryColor,
- Color? primaryColorDark,
- Color? primaryColorLight,
- Color? scaffoldBackgroundColor,
- Color? secondaryHeaderColor,
- Color? shadowColor,
- Color? splashColor,
- Color? unselectedWidgetColor,
- IconThemeData? iconTheme,
- IconThemeData? primaryIconTheme,
- TextTheme? primaryTextTheme,
- TextTheme? textTheme,
- Typography? typography,
- ActionIconThemeData? actionIconTheme,
- AppBarTheme? appBarTheme,
- BadgeThemeData? badgeTheme,
- MaterialBannerThemeData? bannerTheme,
- BottomAppBarTheme? bottomAppBarTheme,
- BottomSheetThemeData? bottomSheetTheme,
- ButtonBarThemeData? buttonBarTheme,
- ButtonThemeData? buttonTheme,
- CardTheme? cardTheme,
- CheckboxThemeData? checkboxTheme,
- ChipThemeData? chipTheme,
- DataTableThemeData? dataTableTheme,
- DatePickerThemeData? datePickerTheme,
- DialogTheme? dialogTheme,
- DividerThemeData? dividerTheme,
- DrawerThemeData? drawerTheme,
- DropdownMenuThemeData? dropdownMenuTheme,
- ElevatedButtonThemeData? elevatedButtonTheme,
- ExpansionTileThemeData? expansionTileTheme,
- FilledButtonThemeData? filledButtonTheme,
- FloatingActionButtonThemeData? floatingActionButtonTheme,
- IconButtonThemeData? iconButtonTheme,
- ListTileThemeData? listTileTheme,
- OutlinedButtonThemeData? outlinedButtonTheme,
- PopupMenuThemeData? popupMenuTheme,
- ProgressIndicatorThemeData? progressIndicatorTheme,
- RadioThemeData? radioTheme,
- SearchBarThemeData? searchBarTheme,
- SearchViewThemeData? searchViewTheme,
- SegmentedButtonThemeData? segmentedButtonTheme,
- SliderThemeData? sliderTheme,
- SnackBarThemeData? snackBarTheme,
- SwitchThemeData? switchTheme,
- TabBarTheme? tabBarTheme,
- TextButtonThemeData? textButtonTheme,
- TextSelectionThemeData? textSelectionTheme,
- TimePickerThemeData? timePickerTheme,
- ToggleButtonsThemeData? toggleButtonsTheme,
- TooltipThemeData? tooltipTheme,
- @Deprecated('Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.') AndroidOverscrollIndicator? androidOverscrollIndicator,
- @Deprecated('No longer used by the framework, please remove any reference to it. ' 'For more information, consult the migration guide at ' 'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. ' 'This feature was deprecated after v3.4.0-19.0.pre.') Color? toggleableActiveColor,
- @Deprecated('No longer used by the framework, please remove any reference to it. ' 'This feature was deprecated after v3.1.0-0.0.pre.') Color? selectedRowColor,
- @Deprecated('Use colorScheme.error instead. ' 'This feature was deprecated after v2.6.0-11.0.pre.') Color? errorColor,
- @Deprecated('Use colorScheme.background instead. ' 'This feature was deprecated after v2.6.0-11.0.pre.') Color? backgroundColor,
- @Deprecated('Use BottomAppBarTheme.color instead. ' 'This feature was deprecated after v3.3.0-0.6.pre.') Color? bottomAppBarColor}
Caches localized themes to speed up the localize method. Creates a copy of this theme but with the given fields replaced with the new values.
The brightness
value is applied to the colorScheme
.
Implementation
/// Creates a copy of this theme but with the given fields replaced with the new values.
///
/// The [brightness] value is applied to the [colorScheme].
ThemeData copyWith({
// For the sanity of the reader, make sure these properties are in the same
// order in every place that they are separated by section comments (e.g.
// GENERAL CONFIGURATION). Each section except for deprecations should be
// alphabetical by symbol name.
// GENERAL CONFIGURATION
bool? applyElevationOverlayColor,
NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
Iterable<ThemeExtension<dynamic>>? extensions,
InputDecorationTheme? inputDecorationTheme,
MaterialTapTargetSize? materialTapTargetSize,
PageTransitionsTheme? pageTransitionsTheme,
TargetPlatform? platform,
ScrollbarThemeData? scrollbarTheme,
InteractiveInkFeatureFactory? splashFactory,
bool? useMaterial3,
VisualDensity? visualDensity,
// COLOR
// [colorScheme] is the preferred way to configure colors. The other color
// properties will gradually be phased out, see
// https://github.com/flutter/flutter/issues/91772.
Brightness? brightness,
Color? canvasColor,
Color? cardColor,
ColorScheme? colorScheme,
Color? dialogBackgroundColor,
Color? disabledColor,
Color? dividerColor,
Color? focusColor,
Color? highlightColor,
Color? hintColor,
Color? hoverColor,
Color? indicatorColor,
Color? primaryColor,
Color? primaryColorDark,
Color? primaryColorLight,
Color? scaffoldBackgroundColor,
Color? secondaryHeaderColor,
Color? shadowColor,
Color? splashColor,
Color? unselectedWidgetColor,
// TYPOGRAPHY & ICONOGRAPHY
IconThemeData? iconTheme,
IconThemeData? primaryIconTheme,
TextTheme? primaryTextTheme,
TextTheme? textTheme,
Typography? typography,
// COMPONENT THEMES
ActionIconThemeData? actionIconTheme,
AppBarTheme? appBarTheme,
BadgeThemeData? badgeTheme,
MaterialBannerThemeData? bannerTheme,
BottomAppBarTheme? bottomAppBarTheme,
BottomNavigationBarThemeData? bottomNavigationBarTheme,
BottomSheetThemeData? bottomSheetTheme,
ButtonBarThemeData? buttonBarTheme,
ButtonThemeData? buttonTheme,
CardTheme? cardTheme,
CheckboxThemeData? checkboxTheme,
ChipThemeData? chipTheme,
DataTableThemeData? dataTableTheme,
DatePickerThemeData? datePickerTheme,
DialogTheme? dialogTheme,
DividerThemeData? dividerTheme,
DrawerThemeData? drawerTheme,
DropdownMenuThemeData? dropdownMenuTheme,
ElevatedButtonThemeData? elevatedButtonTheme,
ExpansionTileThemeData? expansionTileTheme,
FilledButtonThemeData? filledButtonTheme,
FloatingActionButtonThemeData? floatingActionButtonTheme,
IconButtonThemeData? iconButtonTheme,
ListTileThemeData? listTileTheme,
MenuBarThemeData? menuBarTheme,
MenuButtonThemeData? menuButtonTheme,
MenuThemeData? menuTheme,
NavigationBarThemeData? navigationBarTheme,
NavigationDrawerThemeData? navigationDrawerTheme,
NavigationRailThemeData? navigationRailTheme,
OutlinedButtonThemeData? outlinedButtonTheme,
PopupMenuThemeData? popupMenuTheme,
ProgressIndicatorThemeData? progressIndicatorTheme,
RadioThemeData? radioTheme,
SearchBarThemeData? searchBarTheme,
SearchViewThemeData? searchViewTheme,
SegmentedButtonThemeData? segmentedButtonTheme,
SliderThemeData? sliderTheme,
SnackBarThemeData? snackBarTheme,
SwitchThemeData? switchTheme,
TabBarTheme? tabBarTheme,
TextButtonThemeData? textButtonTheme,
TextSelectionThemeData? textSelectionTheme,
TimePickerThemeData? timePickerTheme,
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator? androidOverscrollIndicator,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
'This feature was deprecated after v3.4.0-19.0.pre.',
)
Color? toggleableActiveColor,
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v3.1.0-0.0.pre.',
)
Color? selectedRowColor,
@Deprecated(
'Use colorScheme.error instead. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
Color? errorColor,
@Deprecated(
'Use colorScheme.background instead. '
'This feature was deprecated after v2.6.0-11.0.pre.',
)
Color? backgroundColor,
@Deprecated(
'Use BottomAppBarTheme.color instead. '
'This feature was deprecated after v3.3.0-0.6.pre.',
)
Color? bottomAppBarColor,
}) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
return ThemeData.raw(
// For the sanity of the reader, make sure these properties are in the same
// order in every place that they are separated by section comments (e.g.
// GENERAL CONFIGURATION). Each section except for deprecations should be
// alphabetical by symbol name.
// GENERAL CONFIGURATION
applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme,
extensions: (extensions != null) ? _themeExtensionIterableToMap(extensions) : this.extensions,
inputDecorationTheme: inputDecorationTheme ?? this.inputDecorationTheme,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
platform: platform ?? this.platform,
scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme,
splashFactory: splashFactory ?? this.splashFactory,
useMaterial3: useMaterial3 ?? this.useMaterial3,
visualDensity: visualDensity ?? this.visualDensity,
// COLOR
canvasColor: canvasColor ?? this.canvasColor,
cardColor: cardColor ?? this.cardColor,
colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
disabledColor: disabledColor ?? this.disabledColor,
dividerColor: dividerColor ?? this.dividerColor,
focusColor: focusColor ?? this.focusColor,
highlightColor: highlightColor ?? this.highlightColor,
hintColor: hintColor ?? this.hintColor,
hoverColor: hoverColor ?? this.hoverColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
primaryColor: primaryColor ?? this.primaryColor,
primaryColorDark: primaryColorDark ?? this.primaryColorDark,
primaryColorLight: primaryColorLight ?? this.primaryColorLight,
scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
shadowColor: shadowColor ?? this.shadowColor,
splashColor: splashColor ?? this.splashColor,
unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
// TYPOGRAPHY & ICONOGRAPHY
iconTheme: iconTheme ?? this.iconTheme,
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
textTheme: textTheme ?? this.textTheme,
typography: typography ?? this.typography,
// COMPONENT THEMES
actionIconTheme: actionIconTheme ?? this.actionIconTheme,
appBarTheme: appBarTheme ?? this.appBarTheme,
badgeTheme: badgeTheme ?? this.badgeTheme,
bannerTheme: bannerTheme ?? this.bannerTheme,
bottomAppBarTheme: bottomAppBarTheme ?? this.bottomAppBarTheme,
bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme,
buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
buttonTheme: buttonTheme ?? this.buttonTheme,
cardTheme: cardTheme ?? this.cardTheme,
checkboxTheme: checkboxTheme ?? this.checkboxTheme,
chipTheme: chipTheme ?? this.chipTheme,
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
datePickerTheme: datePickerTheme ?? this.datePickerTheme,
dialogTheme: dialogTheme ?? this.dialogTheme,
dividerTheme: dividerTheme ?? this.dividerTheme,
drawerTheme: drawerTheme ?? this.drawerTheme,
dropdownMenuTheme: dropdownMenuTheme ?? this.dropdownMenuTheme,
elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme,
filledButtonTheme: filledButtonTheme ?? this.filledButtonTheme,
floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme,
iconButtonTheme: iconButtonTheme ?? this.iconButtonTheme,
listTileTheme: listTileTheme ?? this.listTileTheme,
menuBarTheme: menuBarTheme ?? this.menuBarTheme,
menuButtonTheme: menuButtonTheme ?? this.menuButtonTheme,
menuTheme: menuTheme ?? this.menuTheme,
navigationBarTheme: navigationBarTheme ?? this.navigationBarTheme,
navigationDrawerTheme: navigationDrawerTheme ?? this.navigationDrawerTheme,
navigationRailTheme: navigationRailTheme ?? this.navigationRailTheme,
outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
popupMenuTheme: popupMenuTheme ?? this.popupMenuTheme,
progressIndicatorTheme: progressIndicatorTheme ?? this.progressIndicatorTheme,
radioTheme: radioTheme ?? this.radioTheme,
searchBarTheme: searchBarTheme ?? this.searchBarTheme,
searchViewTheme: searchViewTheme ?? this.searchViewTheme,
segmentedButtonTheme: segmentedButtonTheme ?? this.segmentedButtonTheme,
sliderTheme: sliderTheme ?? this.sliderTheme,
snackBarTheme: snackBarTheme ?? this.snackBarTheme,
switchTheme: switchTheme ?? this.switchTheme,
tabBarTheme: tabBarTheme ?? this.tabBarTheme,
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
timePickerTheme: timePickerTheme ?? this.timePickerTheme,
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
selectedRowColor: selectedRowColor ?? _selectedRowColor,
errorColor: errorColor ?? _errorColor,
backgroundColor: backgroundColor ?? _backgroundColor,
bottomAppBarColor: bottomAppBarColor ?? _bottomAppBarColor,
);
}