copyWith method
GBThemeData
copyWith({
- Color? accentColor,
- Color? accentError,
- Color? accentErrorLight,
- Color? backgroundBase,
- Color? backgroundContrast,
- Color? backgroundDisabled,
- Color? backgroundFocus,
- Color? textBase,
- Color? textBlack,
- Color? textDisabled,
- Color? textWhite,
- BorderRadius? textFieldRadius,
- double? textFieldBorderWidth,
- BorderRadius? buttonsRadius,
- ContainedButtonThemeData? containedButtonThemeData,
- Iterable<
Adaptation< ? adaptations,Object> > - bool? applyElevationOverlayColor,
- NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
- Iterable<
ThemeExtension> ? extensions, - Object? inputDecorationTheme,
- MaterialTapTargetSize? materialTapTargetSize,
- PageTransitionsTheme? pageTransitionsTheme,
- TargetPlatform? platform,
- ScrollbarThemeData? scrollbarTheme,
- InteractiveInkFeatureFactory? splashFactory,
- VisualDensity? visualDensity,
- ColorScheme? colorScheme,
- Brightness? brightness,
- Color? canvasColor,
- Color? cardColor,
- Color? disabledColor,
- Color? dividerColor,
- Color? focusColor,
- Color? highlightColor,
- Color? hintColor,
- Color? hoverColor,
- 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,
- Object? appBarTheme,
- BadgeThemeData? badgeTheme,
- MaterialBannerThemeData? bannerTheme,
- BottomAppBarThemeData? bottomAppBarTheme,
- BottomSheetThemeData? bottomSheetTheme,
- ButtonThemeData? buttonTheme,
- CardThemeData? cardTheme,
- CarouselViewThemeData? carouselViewTheme,
- CheckboxThemeData? checkboxTheme,
- ChipThemeData? chipTheme,
- DataTableThemeData? dataTableTheme,
- DatePickerThemeData? datePickerTheme,
- DialogThemeData? 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,
- TabBarThemeData? 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,
- @Deprecated('Use DialogThemeData.backgroundColor instead. ' 'This feature was deprecated after v3.27.0-0.1.pre.') Color? dialogBackgroundColor,
- @Deprecated('Use TabBarThemeData.indicatorColor instead. ' 'This feature was deprecated after v3.28.0-1.0.pre.') Color? indicatorColor,
override
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
@override
/// Creates a copy of this theme but with the given fields replaced with the new values.
///
/// The [brightness] value is applied to the [colorScheme].
GBThemeData copyWith({
Color? accentColor,
Color? accentError,
Color? accentErrorLight,
Color? backgroundBase,
Color? backgroundContrast,
Color? backgroundDisabled,
Color? backgroundFocus,
Color? textBase,
Color? textBlack,
Color? textDisabled,
Color? textWhite,
BorderRadius? textFieldRadius,
double? textFieldBorderWidth,
BorderRadius? buttonsRadius,
ContainedButtonThemeData? containedButtonThemeData,
/* Default Theme */
// GENERAL CONFIGURATION
Iterable<Adaptation<Object>>? adaptations,
bool? applyElevationOverlayColor,
NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
Iterable<ThemeExtension<dynamic>>? extensions,
Object? 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? disabledColor,
Color? dividerColor,
Color? focusColor,
Color? highlightColor,
Color? hintColor,
Color? hoverColor,
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,
// TODO(huycozy): Change the parameter type to AppBarThemeData
Object? appBarTheme,
BadgeThemeData? badgeTheme,
MaterialBannerThemeData? bannerTheme,
BottomAppBarThemeData? bottomAppBarTheme,
BottomNavigationBarThemeData? bottomNavigationBarTheme,
BottomSheetThemeData? bottomSheetTheme,
ButtonThemeData? buttonTheme,
CardThemeData? cardTheme,
CarouselViewThemeData? carouselViewTheme,
CheckboxThemeData? checkboxTheme,
ChipThemeData? chipTheme,
DataTableThemeData? dataTableTheme,
DatePickerThemeData? datePickerTheme,
DialogThemeData? 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,
TabBarThemeData? 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,
@Deprecated(
'Use DialogThemeData.backgroundColor instead. '
'This feature was deprecated after v3.27.0-0.1.pre.',
)
Color? dialogBackgroundColor,
@Deprecated(
'Use TabBarThemeData.indicatorColor instead. '
'This feature was deprecated after v3.28.0-1.0.pre.',
)
Color? indicatorColor,
}) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault() as CupertinoThemeData?;
// TODO(bleroux): Clean this up once the type of `inputDecorationTheme` is changed to `InputDecorationThemeData`
if (inputDecorationTheme != null) {
if (inputDecorationTheme is InputDecorationTheme) {
inputDecorationTheme = inputDecorationTheme.data;
} else if (inputDecorationTheme is! InputDecorationThemeData) {
throw ArgumentError(
'inputDecorationTheme must be either a InputDecorationThemeData or a InputDecorationTheme',
);
}
}
return GBThemeData.raw(
accentColor: accentColor ?? this.accentColor,
accentError: accentError ?? this.accentError,
accentErrorLight: accentErrorLight ?? this.accentErrorLight,
backgroundBase: backgroundBase ?? this.backgroundBase,
backgroundContrast: backgroundContrast ?? this.backgroundContrast,
backgroundDisabled: backgroundDisabled ?? this.backgroundDisabled,
backgroundFocus: backgroundFocus ?? this.backgroundFocus,
textBase: textBase ?? this.textBase,
textBlack: textBlack ?? this.textBlack,
textDisabled: textDisabled ?? this.textDisabled,
textWhite: textWhite ?? this.textWhite,
textFieldRadius: textFieldRadius ?? this.textFieldRadius,
buttonsRadius: buttonsRadius ?? this.buttonsRadius,
textFieldBorderWidth: textFieldBorderWidth ?? this.textFieldBorderWidth,
// containedButtonTheme: containedButtonThemeData ?? this.containedButtonTheme,
containedButtonTheme: _containedButtonTheme(
(containedButtonThemeData ?? this.containedButtonTheme),
accentColor: accentColor ?? this.colorScheme.secondary,
backgroundDisabled: backgroundDisabled ?? this.backgroundDisabled,
buttonsRadius: buttonsRadius,
),
/* DefaultTheme */
// GENERAL CONFIGURATION
adaptationMap: adaptations != null ? _createAdaptationMap(adaptations) : adaptationMap,
applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme,
extensions: (extensions != null) ? _themeExtensionIterableToMap(extensions) : this.extensions,
inputDecorationTheme: _getInputDecorationTheme(
inputDecorationTheme as GBInputDecorationTheme? ?? this.inputDecorationTheme,
accentColor: accentColor ?? this.colorScheme.secondary,
accentError: accentError ?? this.accentError,
accentErrorLight: accentErrorLight ?? this.accentErrorLight,
backgroundBase: backgroundBase ?? this.backgroundBase,
backgroundContrast: backgroundContrast ?? this.backgroundContrast,
backgroundDisabled: backgroundDisabled ?? this.disabledColor,
backgroundFocus: backgroundFocus ?? this.backgroundFocus,
primaryColor: primaryColor ?? this.primaryColor,
textBase: textBase ?? this.textBase,
textBlack: textBlack ?? this.textBlack,
textDisabled: textDisabled ?? this.textDisabled,
textWhite: textWhite ?? this.textWhite,
textFieldRadius: textFieldRadius ?? this.textFieldRadius,
textFieldBorderWidth: textFieldBorderWidth ?? this.textFieldBorderWidth,
),
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),
disabledColor: disabledColor ?? this.disabledColor,
dividerColor: dividerColor ?? this.dividerColor,
focusColor: focusColor ?? this.focusColor,
highlightColor: highlightColor ?? this.highlightColor,
hintColor: hintColor ?? this.hintColor,
hoverColor: hoverColor ?? this.hoverColor,
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,
// TODO(huycozy): Remove this check when appBarTheme is a AppBarThemeData
appBarTheme: () {
if (appBarTheme != null) {
if (appBarTheme is AppBarTheme) {
return appBarTheme.data;
} else if (appBarTheme is! AppBarThemeData) {
throw ArgumentError('appBarTheme must be either a AppBarThemeData or a AppBarTheme');
}
}
return appBarTheme as AppBarThemeData? ?? 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 ?? this.cardTheme,
carouselViewTheme: carouselViewTheme ?? this.carouselViewTheme,
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)
buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
);
}