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. bool? useMaterial3,
  11. VisualDensity? visualDensity,
  12. Color? backgroundColor,
  13. Color? bottomAppBarColor,
  14. Brightness? brightness,
  15. Color? canvasColor,
  16. Color? cardColor,
  17. ColorScheme? colorScheme,
  18. Color? dialogBackgroundColor,
  19. Color? disabledColor,
  20. Color? dividerColor,
  21. Color? errorColor,
  22. Color? focusColor,
  23. Color? highlightColor,
  24. Color? hintColor,
  25. Color? hoverColor,
  26. Color? indicatorColor,
  27. Color? primaryColor,
  28. Color? primaryColorDark,
  29. Color? primaryColorLight,
  30. Color? scaffoldBackgroundColor,
  31. Color? secondaryHeaderColor,
  32. Color? selectedRowColor,
  33. Color? shadowColor,
  34. Color? splashColor,
  35. Color? toggleableActiveColor,
  36. Color? unselectedWidgetColor,
  37. IconThemeData? iconTheme,
  38. IconThemeData? primaryIconTheme,
  39. TextTheme? primaryTextTheme,
  40. TextTheme? textTheme,
  41. Typography? typography,
  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. ExpansionTileThemeData? expansionTileTheme,
  58. FloatingActionButtonThemeData? floatingActionButtonTheme,
  59. ListTileThemeData? listTileTheme,
  60. NavigationBarThemeData? navigationBarTheme,
  61. NavigationRailThemeData? navigationRailTheme,
  62. OutlinedButtonThemeData? outlinedButtonTheme,
  63. PopupMenuThemeData? popupMenuTheme,
  64. ProgressIndicatorThemeData? progressIndicatorTheme,
  65. RadioThemeData? radioTheme,
  66. SliderThemeData? sliderTheme,
  67. SnackBarThemeData? snackBarTheme,
  68. SwitchThemeData? switchTheme,
  69. TabBarTheme? tabBarTheme,
  70. TextButtonThemeData? textButtonTheme,
  71. TextSelectionThemeData? textSelectionTheme,
  72. TimePickerThemeData? timePickerTheme,
  73. ToggleButtonsThemeData? toggleButtonsTheme,
  74. TooltipThemeData? tooltipTheme,
  75. @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,
  76. @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,
  77. @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,
  78. @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,
  79. @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,
  80. @Deprecated('This "fix" is now enabled by default. ' 'This feature was deprecated after v2.5.0-1.0.pre.') bool? fixTextFieldOutlineLabel,
  81. @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,
  82. @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({
  // 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
  bool? applyElevationOverlayColor,
  NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  Iterable<ThemeExtension<dynamic>>? extensions,
  InputDecorationTheme? inputDecorationTheme,
  MaterialTapTargetSize? materialTapTargetSize,
  PageTransitionsTheme? pageTransitionsTheme,
  TargetPlatform? platform,
  ScrollbarThemeData? scrollbarTheme,
  InteractiveInkFeatureFactory? splashFactory,
  bool? useMaterial3,
  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.
  Color? backgroundColor,
  Color? bottomAppBarColor,
  Brightness? brightness,
  Color? canvasColor,
  Color? cardColor,
  ColorScheme? colorScheme,
  Color? dialogBackgroundColor,
  Color? disabledColor,
  Color? dividerColor,
  Color? errorColor,
  Color? focusColor,
  Color? highlightColor,
  Color? hintColor,
  Color? hoverColor,
  Color? indicatorColor,
  Color? primaryColor,
  Color? primaryColorDark,
  Color? primaryColorLight,
  Color? scaffoldBackgroundColor,
  Color? secondaryHeaderColor,
  Color? selectedRowColor,
  Color? shadowColor,
  Color? splashColor,
  Color? toggleableActiveColor,
  Color? unselectedWidgetColor,
  // TYPOGRAPHY & ICONOGRAPHY
  IconThemeData? iconTheme,
  IconThemeData? primaryIconTheme,
  TextTheme? primaryTextTheme,
  TextTheme? textTheme,
  Typography? typography,
  // 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,
  ExpansionTileThemeData? expansionTileTheme,
  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,
  // 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/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(
    // 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
    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,
    useMaterial3: useMaterial3 ?? this.useMaterial3,
    visualDensity: visualDensity ?? this.visualDensity,
    // COLOR
    backgroundColor: backgroundColor ?? this.backgroundColor,
    bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
    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,
    errorColor: errorColor ?? this.errorColor,
    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,
    selectedRowColor: selectedRowColor ?? this.selectedRowColor,
    shadowColor: shadowColor ?? this.shadowColor,
    splashColor: splashColor ?? this.splashColor,
    toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
    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
    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,
    expansionTileTheme: expansionTileTheme ?? this.expansionTileTheme,
    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,
    // DEPRECATED (newest deprecations at the bottom)
    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,
  );
}