copyWith method
- Iterable<
Adaptation< ? adaptations,Object> > - bool? applyElevationOverlayColor,
- NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
- Iterable<
ThemeExtension> ? extensions, - InputDecorationTheme? inputDecorationTheme,
- MaterialTapTargetSize? materialTapTargetSize,
- PageTransitionsTheme? pageTransitionsTheme,
- TargetPlatform? platform,
- ScrollbarThemeData? scrollbarTheme,
- InteractiveInkFeatureFactory? splashFactory,
- VisualDensity? visualDensity,
- ColorScheme? colorScheme,
- Brightness? brightness,
- Color? canvasColor,
- Color? cardColor,
- 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,
- ButtonThemeData? buttonTheme,
- Object? cardTheme,
- CheckboxThemeData? checkboxTheme,
- ChipThemeData? chipTheme,
- DataTableThemeData? dataTableTheme,
- DatePickerThemeData? datePickerTheme,
- Object? 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,
- Object? tabBarTheme,
- TextButtonThemeData? textButtonTheme,
- TextSelectionThemeData? textSelectionTheme,
- TimePickerThemeData? timePickerTheme,
- ToggleButtonsThemeData? toggleButtonsTheme,
- TooltipThemeData? tooltipTheme,
- @Deprecated('Use a ThemeData constructor (.from, .light, or .dark) instead. ' 'These constructors all have a useMaterial3 argument, ' 'and they set appropriate default values based on its value. ' 'See the useMaterial3 API documentation for full details. ' 'This feature was deprecated after v3.13.0-0.2.pre.') bool? useMaterial3,
- @Deprecated('Use OverflowBar instead. ' 'This feature was deprecated after v3.21.0-10.0.pre.') ButtonBarThemeData? buttonBarTheme,
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
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
Iterable<Adaptation<Object>>? adaptations,
bool? applyElevationOverlayColor,
NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
Iterable<ThemeExtension<dynamic>>? extensions,
InputDecorationTheme? inputDecorationTheme,
MaterialTapTargetSize? materialTapTargetSize,
PageTransitionsTheme? pageTransitionsTheme,
TargetPlatform? platform,
ScrollbarThemeData? scrollbarTheme,
InteractiveInkFeatureFactory? splashFactory,
VisualDensity? visualDensity,
// COLOR
ColorScheme? colorScheme,
Brightness? brightness,
// [colorScheme] is the preferred way to configure colors. The [Color] properties
// listed below (as well as primarySwatch) will gradually be phased out, see
// https://github.com/flutter/flutter/issues/91772.
Color? canvasColor,
Color? cardColor,
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,
ButtonThemeData? buttonTheme,
Object? cardTheme,
CheckboxThemeData? checkboxTheme,
ChipThemeData? chipTheme,
DataTableThemeData? dataTableTheme,
DatePickerThemeData? datePickerTheme,
// TODO(QuncCccccc): Change the parameter type to DialogThemeData
Object? 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,
// TODO(QuncCccccc): Change the parameter type to TabBarThemeData
Object? tabBarTheme,
TextButtonThemeData? textButtonTheme,
TextSelectionThemeData? textSelectionTheme,
TimePickerThemeData? timePickerTheme,
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated(
'Use a ThemeData constructor (.from, .light, or .dark) instead. '
'These constructors all have a useMaterial3 argument, '
'and they set appropriate default values based on its value. '
'See the useMaterial3 API documentation for full details. '
'This feature was deprecated after v3.13.0-0.2.pre.',
)
bool? useMaterial3,
@Deprecated(
'Use OverflowBar instead. '
'This feature was deprecated after v3.21.0-10.0.pre.',
)
ButtonBarThemeData? buttonBarTheme,
}) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
// TODO(QuncCccccc): Clean it up once the type of `cardTheme` is changed to `CardThemeData`
if (cardTheme != null) {
if (cardTheme is CardTheme) {
cardTheme = cardTheme.data;
} else if (cardTheme is! CardThemeData) {
throw ArgumentError('cardTheme must be either a CardThemeData or a CardTheme');
}
}
// TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
if (dialogTheme != null) {
if (dialogTheme is DialogTheme) {
dialogTheme = dialogTheme.data;
} else if (dialogTheme is! DialogThemeData) {
throw ArgumentError('dialogTheme must be either a DialogThemeData or a DialogTheme');
}
}
// TODO(QuncCccccc): Clean this up once the type of `tabBarTheme` is changed to `TabBarThemeData`
if (tabBarTheme != null) {
if (tabBarTheme is TabBarTheme) {
tabBarTheme = tabBarTheme.data;
} else if (tabBarTheme is! TabBarThemeData) {
throw ArgumentError('tabBarTheme must be either a TabBarThemeData or a TabBarTheme');
}
}
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
adaptationMap: adaptations != null ? _createAdaptationMap(adaptations) : adaptationMap,
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,
// When deprecated useMaterial3 removed, maintain `this.useMaterial3` here
// for == evaluation.
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,
buttonTheme: buttonTheme ?? this.buttonTheme,
cardTheme: cardTheme as CardThemeData? ?? this.cardTheme,
checkboxTheme: checkboxTheme ?? this.checkboxTheme,
chipTheme: chipTheme ?? this.chipTheme,
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
datePickerTheme: datePickerTheme ?? this.datePickerTheme,
dialogTheme: dialogTheme as DialogThemeData? ?? 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 as TabBarThemeData? ?? this.tabBarTheme,
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
timePickerTheme: timePickerTheme ?? this.timePickerTheme,
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
buttonBarTheme: buttonBarTheme ?? _buttonBarTheme,
);
}