copyWith method Null safety

ThemeData copyWith(
  1. {bool? applyElevationOverlayColor,
  2. NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  3. Iterable<ThemeExtension>? extensions,
  4. InputDecorationTheme? inputDecorationTheme,
  5. MaterialTapTargetSize? materialTapTargetSize,
  6. PageTransitionsTheme? pageTransitionsTheme,
  7. TargetPlatform? platform,
  8. ScrollbarThemeData? scrollbarTheme,
  9. InteractiveInkFeatureFactory? splashFactory,
  10. VisualDensity? visualDensity,
  11. bool? useMaterial3,
  12. ColorScheme? colorScheme,
  13. Brightness? brightness,
  14. Color? primaryColor,
  15. Color? primaryColorLight,
  16. Color? primaryColorDark,
  17. Color? focusColor,
  18. Color? hoverColor,
  19. Color? shadowColor,
  20. Color? canvasColor,
  21. Color? scaffoldBackgroundColor,
  22. Color? bottomAppBarColor,
  23. Color? cardColor,
  24. Color? dividerColor,
  25. Color? highlightColor,
  26. Color? splashColor,
  27. Color? selectedRowColor,
  28. Color? unselectedWidgetColor,
  29. Color? disabledColor,
  30. Color? secondaryHeaderColor,
  31. Color? backgroundColor,
  32. Color? dialogBackgroundColor,
  33. Color? indicatorColor,
  34. Color? hintColor,
  35. Color? errorColor,
  36. Color? toggleableActiveColor,
  37. Typography? typography,
  38. TextTheme? textTheme,
  39. TextTheme? primaryTextTheme,
  40. IconThemeData? iconTheme,
  41. IconThemeData? primaryIconTheme,
  42. AppBarTheme? appBarTheme,
  43. MaterialBannerThemeData? bannerTheme,
  44. BottomAppBarTheme? bottomAppBarTheme,
  45. BottomNavigationBarThemeData? bottomNavigationBarTheme,
  46. BottomSheetThemeData? bottomSheetTheme,
  47. ButtonBarThemeData? buttonBarTheme,
  48. ButtonThemeData? buttonTheme,
  49. CardTheme? cardTheme,
  50. CheckboxThemeData? checkboxTheme,
  51. ChipThemeData? chipTheme,
  52. DataTableThemeData? dataTableTheme,
  53. DialogTheme? dialogTheme,
  54. DividerThemeData? dividerTheme,
  55. DrawerThemeData? drawerTheme,
  56. ElevatedButtonThemeData? elevatedButtonTheme,
  57. FloatingActionButtonThemeData? floatingActionButtonTheme,
  58. ListTileThemeData? listTileTheme,
  59. NavigationBarThemeData? navigationBarTheme,
  60. NavigationRailThemeData? navigationRailTheme,
  61. OutlinedButtonThemeData? outlinedButtonTheme,
  62. PopupMenuThemeData? popupMenuTheme,
  63. ProgressIndicatorThemeData? progressIndicatorTheme,
  64. RadioThemeData? radioTheme,
  65. SliderThemeData? sliderTheme,
  66. SnackBarThemeData? snackBarTheme,
  67. SwitchThemeData? switchTheme,
  68. TabBarTheme? tabBarTheme,
  69. TextButtonThemeData? textButtonTheme,
  70. TextSelectionThemeData? textSelectionTheme,
  71. TimePickerThemeData? timePickerTheme,
  72. ToggleButtonsThemeData? toggleButtonsTheme,
  73. TooltipThemeData? tooltipTheme,
  74. ExpansionTileThemeData? expansionTileTheme,
  75. @Deprecated('No longer used by the framework, please remove any reference to it. ' 'This feature was deprecated after v1.23.0-4.0.pre.') bool? useTextSelectionTheme,
  76. @Deprecated('Use TextSelectionThemeData.selectionColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? textSelectionColor,
  77. @Deprecated('Use TextSelectionThemeData.cursorColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? cursorColor,
  78. @Deprecated('Use TextSelectionThemeData.selectionHandleColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? textSelectionHandleColor,
  79. @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/theme-data-accent-properties#migration-guide. ' 'This feature was deprecated after v2.3.0-0.1.pre.') Color? accentColor,
  80. @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/theme-data-accent-properties#migration-guide. ' 'This feature was deprecated after v2.3.0-0.1.pre.') Brightness? accentColorBrightness,
  81. @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/theme-data-accent-properties#migration-guide. ' 'This feature was deprecated after v2.3.0-0.1.pre.') TextTheme? accentTextTheme,
  82. @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/theme-data-accent-properties#migration-guide. ' 'This feature was deprecated after v2.3.0-0.1.pre.') IconThemeData? accentIconTheme,
  83. @Deprecated('No longer used by the framework, please remove any reference to it. ' 'This feature was deprecated after v2.3.0-0.2.pre.') Color? buttonColor,
  84. @Deprecated('This "fix" is now enabled by default. ' 'This feature was deprecated after v2.5.0-1.0.pre.') bool? fixTextFieldOutlineLabel,
  85. @Deprecated('No longer used by the framework, please remove any reference to it. ' 'This feature was deprecated after v2.6.0-11.0.pre.') Brightness? primaryColorBrightness,
  86. @Deprecated('Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. ' 'This feature was deprecated after v2.13.0-0.0.pre.') AndroidOverscrollIndicator? androidOverscrollIndicator}
)

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({
  // GENERAL CONFIGURATION
  bool? applyElevationOverlayColor,
  NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  Iterable<ThemeExtension<dynamic>>? extensions,
  InputDecorationTheme? inputDecorationTheme,
  MaterialTapTargetSize? materialTapTargetSize,
  PageTransitionsTheme? pageTransitionsTheme,
  TargetPlatform? platform,
  ScrollbarThemeData? scrollbarTheme,
  InteractiveInkFeatureFactory? splashFactory,
  VisualDensity? visualDensity,
  bool? useMaterial3,
  // 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.
  ColorScheme? colorScheme,
  Brightness? brightness,
  Color? primaryColor,
  Color? primaryColorLight,
  Color? primaryColorDark,
  Color? focusColor,
  Color? hoverColor,
  Color? shadowColor,
  Color? canvasColor,
  Color? scaffoldBackgroundColor,
  Color? bottomAppBarColor,
  Color? cardColor,
  Color? dividerColor,
  Color? highlightColor,
  Color? splashColor,
  Color? selectedRowColor,
  Color? unselectedWidgetColor,
  Color? disabledColor,
  Color? secondaryHeaderColor,
  Color? backgroundColor,
  Color? dialogBackgroundColor,
  Color? indicatorColor,
  Color? hintColor,
  Color? errorColor,
  Color? toggleableActiveColor,
  // TYPOGRAPHY & ICONOGRAPHY
  Typography? typography,
  TextTheme? textTheme,
  TextTheme? primaryTextTheme,
  IconThemeData? iconTheme,
  IconThemeData? primaryIconTheme,
  // COMPONENT THEMES
  AppBarTheme? appBarTheme,
  MaterialBannerThemeData? bannerTheme,
  BottomAppBarTheme? bottomAppBarTheme,
  BottomNavigationBarThemeData? bottomNavigationBarTheme,
  BottomSheetThemeData? bottomSheetTheme,
  ButtonBarThemeData? buttonBarTheme,
  ButtonThemeData? buttonTheme,
  CardTheme? cardTheme,
  CheckboxThemeData? checkboxTheme,
  ChipThemeData? chipTheme,
  DataTableThemeData? dataTableTheme,
  DialogTheme? dialogTheme,
  DividerThemeData? dividerTheme,
  DrawerThemeData? drawerTheme,
  ElevatedButtonThemeData? elevatedButtonTheme,
  FloatingActionButtonThemeData? floatingActionButtonTheme,
  ListTileThemeData? listTileTheme,
  NavigationBarThemeData? navigationBarTheme,
  NavigationRailThemeData? navigationRailTheme,
  OutlinedButtonThemeData? outlinedButtonTheme,
  PopupMenuThemeData? popupMenuTheme,
  ProgressIndicatorThemeData? progressIndicatorTheme,
  RadioThemeData? radioTheme,
  SliderThemeData? sliderTheme,
  SnackBarThemeData? snackBarTheme,
  SwitchThemeData? switchTheme,
  TabBarTheme? tabBarTheme,
  TextButtonThemeData? textButtonTheme,
  TextSelectionThemeData? textSelectionTheme,
  TimePickerThemeData? timePickerTheme,
  ToggleButtonsThemeData? toggleButtonsTheme,
  TooltipThemeData? tooltipTheme,
  ExpansionTileThemeData? expansionTileTheme,
  // DEPRECATED (newest deprecations at the bottom)
  @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'This feature was deprecated after v1.23.0-4.0.pre.',
  )
  bool? useTextSelectionTheme,
  @Deprecated(
    'Use TextSelectionThemeData.selectionColor instead. '
    'This feature was deprecated after v1.26.0-18.0.pre.',
  )
  Color? textSelectionColor,
  @Deprecated(
    'Use TextSelectionThemeData.cursorColor instead. '
    'This feature was deprecated after v1.26.0-18.0.pre.',
  )
  Color? cursorColor,
  @Deprecated(
    'Use TextSelectionThemeData.selectionHandleColor instead. '
    'This feature was deprecated after v1.26.0-18.0.pre.',
  )
  Color? textSelectionHandleColor,
  @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/theme-data-accent-properties#migration-guide. '
    'This feature was deprecated after v2.3.0-0.1.pre.',
  )
  Color? accentColor,
  @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/theme-data-accent-properties#migration-guide. '
    'This feature was deprecated after v2.3.0-0.1.pre.',
  )
  Brightness? accentColorBrightness,
  @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/theme-data-accent-properties#migration-guide. '
    'This feature was deprecated after v2.3.0-0.1.pre.',
  )
  TextTheme? accentTextTheme,
  @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/theme-data-accent-properties#migration-guide. '
    'This feature was deprecated after v2.3.0-0.1.pre.',
  )
  IconThemeData? accentIconTheme,
  @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'This feature was deprecated after v2.3.0-0.2.pre.',
  )
  Color? buttonColor,
  @Deprecated(
    'This "fix" is now enabled by default. '
    'This feature was deprecated after v2.5.0-1.0.pre.',
  )
  bool? fixTextFieldOutlineLabel,
  @Deprecated(
    'No longer used by the framework, please remove any reference to it. '
    'This feature was deprecated after v2.6.0-11.0.pre.',
  )
  Brightness? primaryColorBrightness,
  @Deprecated(
    'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
    'This feature was deprecated after v2.13.0-0.0.pre.'
  )
  AndroidOverscrollIndicator? androidOverscrollIndicator,
}) {
  cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
  return ThemeData.raw(
    // 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,
    visualDensity: visualDensity ?? this.visualDensity,
    useMaterial3: useMaterial3 ?? this.useMaterial3,
    // COLOR
    colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
    primaryColor: primaryColor ?? this.primaryColor,
    primaryColorLight: primaryColorLight ?? this.primaryColorLight,
    primaryColorDark: primaryColorDark ?? this.primaryColorDark,
    focusColor: focusColor ?? this.focusColor,
    hoverColor: hoverColor ?? this.hoverColor,
    shadowColor: shadowColor ?? this.shadowColor,
    canvasColor: canvasColor ?? this.canvasColor,
    scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
    bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
    cardColor: cardColor ?? this.cardColor,
    dividerColor: dividerColor ?? this.dividerColor,
    highlightColor: highlightColor ?? this.highlightColor,
    splashColor: splashColor ?? this.splashColor,
    selectedRowColor: selectedRowColor ?? this.selectedRowColor,
    unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
    disabledColor: disabledColor ?? this.disabledColor,
    secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
    backgroundColor: backgroundColor ?? this.backgroundColor,
    dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
    indicatorColor: indicatorColor ?? this.indicatorColor,
    hintColor: hintColor ?? this.hintColor,
    errorColor: errorColor ?? this.errorColor,
    toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
    // TYPOGRAPHY & ICONOGRAPHY
    typography: typography ?? this.typography,
    textTheme: textTheme ?? this.textTheme,
    primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
    iconTheme: iconTheme ?? this.iconTheme,
    primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
    // COMPONENT THEMES
    appBarTheme: appBarTheme ?? this.appBarTheme,
    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,
    dialogTheme: dialogTheme ?? this.dialogTheme,
    dividerTheme: dividerTheme ?? this.dividerTheme,
    drawerTheme: drawerTheme ?? this.drawerTheme,
    elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
    floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme,
    listTileTheme: listTileTheme ?? this.listTileTheme,
    navigationBarTheme: navigationBarTheme ?? this.navigationBarTheme,
    navigationRailTheme: navigationRailTheme ?? this.navigationRailTheme,
    outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
    popupMenuTheme: popupMenuTheme ?? this.popupMenuTheme,
    progressIndicatorTheme: progressIndicatorTheme ?? this.progressIndicatorTheme,
    radioTheme: radioTheme ?? this.radioTheme,
    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,
    expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme,
    // DEPRECATED (newest deprecations at the bottom)
    useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme,
    textSelectionColor: textSelectionColor ?? this.textSelectionColor,
    cursorColor: cursorColor ?? this.cursorColor,
    textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
    accentColor: accentColor ?? this.accentColor,
    accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
    accentTextTheme: accentTextTheme ?? this.accentTextTheme,
    accentIconTheme: accentIconTheme ?? this.accentIconTheme,
    buttonColor: buttonColor ?? this.buttonColor,
    fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
    primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
    androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
  );
}