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. ColorScheme? colorScheme,
  13. Brightness? brightness,
  14. Color? canvasColor,
  15. Color? cardColor,
  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. ButtonThemeData? buttonTheme,
  45. CardTheme? cardTheme,
  46. CheckboxThemeData? checkboxTheme,
  47. ChipThemeData? chipTheme,
  48. DataTableThemeData? dataTableTheme,
  49. DatePickerThemeData? datePickerTheme,
  50. DialogTheme? dialogTheme,
  51. DividerThemeData? dividerTheme,
  52. DrawerThemeData? drawerTheme,
  53. DropdownMenuThemeData? dropdownMenuTheme,
  54. ElevatedButtonThemeData? elevatedButtonTheme,
  55. ExpansionTileThemeData? expansionTileTheme,
  56. FilledButtonThemeData? filledButtonTheme,
  57. FloatingActionButtonThemeData? floatingActionButtonTheme,
  58. IconButtonThemeData? iconButtonTheme,
  59. ListTileThemeData? listTileTheme,
  60. MenuBarThemeData? menuBarTheme,
  61. MenuButtonThemeData? menuButtonTheme,
  62. MenuThemeData? menuTheme,
  63. NavigationBarThemeData? navigationBarTheme,
  64. NavigationDrawerThemeData? navigationDrawerTheme,
  65. NavigationRailThemeData? navigationRailTheme,
  66. OutlinedButtonThemeData? outlinedButtonTheme,
  67. PopupMenuThemeData? popupMenuTheme,
  68. ProgressIndicatorThemeData? progressIndicatorTheme,
  69. RadioThemeData? radioTheme,
  70. SearchBarThemeData? searchBarTheme,
  71. SearchViewThemeData? searchViewTheme,
  72. SegmentedButtonThemeData? segmentedButtonTheme,
  73. SliderThemeData? sliderTheme,
  74. SnackBarThemeData? snackBarTheme,
  75. SwitchThemeData? switchTheme,
  76. TabBarTheme? tabBarTheme,
  77. TextButtonThemeData? textButtonTheme,
  78. TextSelectionThemeData? textSelectionTheme,
  79. TimePickerThemeData? timePickerTheme,
  80. ToggleButtonsThemeData? toggleButtonsTheme,
  81. TooltipThemeData? tooltipTheme,
  82. @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,
  83. @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,
  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 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();
  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 ?? 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,
    buttonBarTheme: buttonBarTheme ?? _buttonBarTheme,
  );
}