copyWith method

ThemeData copyWith(
  1. {Iterable<Adaptation<Object>>? adaptations,
  2. bool? applyElevationOverlayColor,
  3. NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  4. Iterable<ThemeExtension>? extensions,
  5. InputDecorationTheme? inputDecorationTheme,
  6. MaterialTapTargetSize? materialTapTargetSize,
  7. PageTransitionsTheme? pageTransitionsTheme,
  8. TargetPlatform? platform,
  9. ScrollbarThemeData? scrollbarTheme,
  10. InteractiveInkFeatureFactory? splashFactory,
  11. VisualDensity? visualDensity,
  12. Brightness? brightness,
  13. Color? canvasColor,
  14. Color? cardColor,
  15. ColorScheme? colorScheme,
  16. Color? dialogBackgroundColor,
  17. Color? disabledColor,
  18. Color? dividerColor,
  19. Color? focusColor,
  20. Color? highlightColor,
  21. Color? hintColor,
  22. Color? hoverColor,
  23. Color? indicatorColor,
  24. Color? primaryColor,
  25. Color? primaryColorDark,
  26. Color? primaryColorLight,
  27. Color? scaffoldBackgroundColor,
  28. Color? secondaryHeaderColor,
  29. Color? shadowColor,
  30. Color? splashColor,
  31. Color? unselectedWidgetColor,
  32. IconThemeData? iconTheme,
  33. IconThemeData? primaryIconTheme,
  34. TextTheme? primaryTextTheme,
  35. TextTheme? textTheme,
  36. Typography? typography,
  37. ActionIconThemeData? actionIconTheme,
  38. AppBarTheme? appBarTheme,
  39. BadgeThemeData? badgeTheme,
  40. MaterialBannerThemeData? bannerTheme,
  41. BottomAppBarTheme? bottomAppBarTheme,
  42. BottomNavigationBarThemeData? bottomNavigationBarTheme,
  43. BottomSheetThemeData? bottomSheetTheme,
  44. ButtonBarThemeData? buttonBarTheme,
  45. ButtonThemeData? buttonTheme,
  46. CardTheme? cardTheme,
  47. CheckboxThemeData? checkboxTheme,
  48. ChipThemeData? chipTheme,
  49. DataTableThemeData? dataTableTheme,
  50. DatePickerThemeData? datePickerTheme,
  51. DialogTheme? dialogTheme,
  52. DividerThemeData? dividerTheme,
  53. DrawerThemeData? drawerTheme,
  54. DropdownMenuThemeData? dropdownMenuTheme,
  55. ElevatedButtonThemeData? elevatedButtonTheme,
  56. ExpansionTileThemeData? expansionTileTheme,
  57. FilledButtonThemeData? filledButtonTheme,
  58. FloatingActionButtonThemeData? floatingActionButtonTheme,
  59. IconButtonThemeData? iconButtonTheme,
  60. ListTileThemeData? listTileTheme,
  61. MenuBarThemeData? menuBarTheme,
  62. MenuButtonThemeData? menuButtonTheme,
  63. MenuThemeData? menuTheme,
  64. NavigationBarThemeData? navigationBarTheme,
  65. NavigationDrawerThemeData? navigationDrawerTheme,
  66. NavigationRailThemeData? navigationRailTheme,
  67. OutlinedButtonThemeData? outlinedButtonTheme,
  68. PopupMenuThemeData? popupMenuTheme,
  69. ProgressIndicatorThemeData? progressIndicatorTheme,
  70. RadioThemeData? radioTheme,
  71. SearchBarThemeData? searchBarTheme,
  72. SearchViewThemeData? searchViewTheme,
  73. SegmentedButtonThemeData? segmentedButtonTheme,
  74. SliderThemeData? sliderTheme,
  75. SnackBarThemeData? snackBarTheme,
  76. SwitchThemeData? switchTheme,
  77. TabBarTheme? tabBarTheme,
  78. TextButtonThemeData? textButtonTheme,
  79. TextSelectionThemeData? textSelectionTheme,
  80. TimePickerThemeData? timePickerTheme,
  81. ToggleButtonsThemeData? toggleButtonsTheme,
  82. TooltipThemeData? tooltipTheme,
  83. @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,
  84. @Deprecated('Use colorScheme.error instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.') Color? errorColor,
  85. @Deprecated('Use colorScheme.background instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.') Color? backgroundColor,
  86. @Deprecated('Use BottomAppBarTheme.color instead. ' 'This feature was deprecated after v3.3.0-0.6.pre.') Color? bottomAppBarColor,
  87. @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}
)

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] 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(
    '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(
    'Use colorScheme.error instead. '
    'This feature was deprecated after v3.3.0-0.5.pre.',
  )
  Color? errorColor,
  @Deprecated(
    'Use colorScheme.background instead. '
    'This feature was deprecated after v3.3.0-0.5.pre.',
  )
  Color? backgroundColor,
  @Deprecated(
    'Use BottomAppBarTheme.color instead. '
    'This feature was deprecated after v3.3.0-0.6.pre.',
  )
  Color? bottomAppBarColor,
  @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,
}) {
  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
    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,
    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)
    toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
    errorColor: errorColor ?? _errorColor,
    backgroundColor: backgroundColor ?? _backgroundColor,
    bottomAppBarColor: bottomAppBarColor ?? _bottomAppBarColor,
  );
}