copyWith method Null safety

ThemeData copyWith(
  1. {Brightness? brightness,
  2. VisualDensity? visualDensity,
  3. Color? primaryColor,
  4. Brightness? primaryColorBrightness,
  5. Color? primaryColorLight,
  6. Color? primaryColorDark,
  7. Color? accentColor,
  8. Brightness? accentColorBrightness,
  9. Color? canvasColor,
  10. Color? shadowColor,
  11. Color? scaffoldBackgroundColor,
  12. Color? bottomAppBarColor,
  13. Color? cardColor,
  14. Color? dividerColor,
  15. Color? focusColor,
  16. Color? hoverColor,
  17. Color? highlightColor,
  18. Color? splashColor,
  19. InteractiveInkFeatureFactory? splashFactory,
  20. Color? selectedRowColor,
  21. Color? unselectedWidgetColor,
  22. Color? disabledColor,
  23. ButtonThemeData? buttonTheme,
  24. ToggleButtonsThemeData? toggleButtonsTheme,
  25. Color? buttonColor,
  26. Color? secondaryHeaderColor,
  27. @Deprecated('Use TextSelectionThemeData.selectionColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? textSelectionColor,
  28. @Deprecated('Use TextSelectionThemeData.cursorColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? cursorColor,
  29. @Deprecated('Use TextSelectionThemeData.selectionHandleColor instead. ' 'This feature was deprecated after v1.26.0-18.0.pre.') Color? textSelectionHandleColor,
  30. Color? backgroundColor,
  31. Color? dialogBackgroundColor,
  32. Color? indicatorColor,
  33. Color? hintColor,
  34. Color? errorColor,
  35. Color? toggleableActiveColor,
  36. TextTheme? textTheme,
  37. TextTheme? primaryTextTheme,
  38. TextTheme? accentTextTheme,
  39. InputDecorationTheme? inputDecorationTheme,
  40. IconThemeData? iconTheme,
  41. IconThemeData? primaryIconTheme,
  42. IconThemeData? accentIconTheme,
  43. SliderThemeData? sliderTheme,
  44. TabBarTheme? tabBarTheme,
  45. TooltipThemeData? tooltipTheme,
  46. CardTheme? cardTheme,
  47. ChipThemeData? chipTheme,
  48. TargetPlatform? platform,
  49. MaterialTapTargetSize? materialTapTargetSize,
  50. bool? applyElevationOverlayColor,
  51. PageTransitionsTheme? pageTransitionsTheme,
  52. AppBarTheme? appBarTheme,
  53. ScrollbarThemeData? scrollbarTheme,
  54. BottomAppBarTheme? bottomAppBarTheme,
  55. ColorScheme? colorScheme,
  56. DialogTheme? dialogTheme,
  57. FloatingActionButtonThemeData? floatingActionButtonTheme,
  58. NavigationRailThemeData? navigationRailTheme,
  59. Typography? typography,
  60. NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  61. SnackBarThemeData? snackBarTheme,
  62. BottomSheetThemeData? bottomSheetTheme,
  63. PopupMenuThemeData? popupMenuTheme,
  64. MaterialBannerThemeData? bannerTheme,
  65. DividerThemeData? dividerTheme,
  66. ButtonBarThemeData? buttonBarTheme,
  67. BottomNavigationBarThemeData? bottomNavigationBarTheme,
  68. TimePickerThemeData? timePickerTheme,
  69. TextButtonThemeData? textButtonTheme,
  70. ElevatedButtonThemeData? elevatedButtonTheme,
  71. OutlinedButtonThemeData? outlinedButtonTheme,
  72. TextSelectionThemeData? textSelectionTheme,
  73. DataTableThemeData? dataTableTheme,
  74. CheckboxThemeData? checkboxTheme,
  75. RadioThemeData? radioTheme,
  76. SwitchThemeData? switchTheme,
  77. bool? fixTextFieldOutlineLabel,
  78. @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}
)

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({
  Brightness? brightness,
  VisualDensity? visualDensity,
  Color? primaryColor,
  Brightness? primaryColorBrightness,
  Color? primaryColorLight,
  Color? primaryColorDark,
  Color? accentColor,
  Brightness? accentColorBrightness,
  Color? canvasColor,
  Color? shadowColor,
  Color? scaffoldBackgroundColor,
  Color? bottomAppBarColor,
  Color? cardColor,
  Color? dividerColor,
  Color? focusColor,
  Color? hoverColor,
  Color? highlightColor,
  Color? splashColor,
  InteractiveInkFeatureFactory? splashFactory,
  Color? selectedRowColor,
  Color? unselectedWidgetColor,
  Color? disabledColor,
  ButtonThemeData? buttonTheme,
  ToggleButtonsThemeData? toggleButtonsTheme,
  Color? buttonColor,
  Color? secondaryHeaderColor,
  @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,
  Color? backgroundColor,
  Color? dialogBackgroundColor,
  Color? indicatorColor,
  Color? hintColor,
  Color? errorColor,
  Color? toggleableActiveColor,
  TextTheme? textTheme,
  TextTheme? primaryTextTheme,
  TextTheme? accentTextTheme,
  InputDecorationTheme? inputDecorationTheme,
  IconThemeData? iconTheme,
  IconThemeData? primaryIconTheme,
  IconThemeData? accentIconTheme,
  SliderThemeData? sliderTheme,
  TabBarTheme? tabBarTheme,
  TooltipThemeData? tooltipTheme,
  CardTheme? cardTheme,
  ChipThemeData? chipTheme,
  TargetPlatform? platform,
  MaterialTapTargetSize? materialTapTargetSize,
  bool? applyElevationOverlayColor,
  PageTransitionsTheme? pageTransitionsTheme,
  AppBarTheme? appBarTheme,
  ScrollbarThemeData? scrollbarTheme,
  BottomAppBarTheme? bottomAppBarTheme,
  ColorScheme? colorScheme,
  DialogTheme? dialogTheme,
  FloatingActionButtonThemeData? floatingActionButtonTheme,
  NavigationRailThemeData? navigationRailTheme,
  Typography? typography,
  NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  SnackBarThemeData? snackBarTheme,
  BottomSheetThemeData? bottomSheetTheme,
  PopupMenuThemeData? popupMenuTheme,
  MaterialBannerThemeData? bannerTheme,
  DividerThemeData? dividerTheme,
  ButtonBarThemeData? buttonBarTheme,
  BottomNavigationBarThemeData? bottomNavigationBarTheme,
  TimePickerThemeData? timePickerTheme,
  TextButtonThemeData? textButtonTheme,
  ElevatedButtonThemeData? elevatedButtonTheme,
  OutlinedButtonThemeData? outlinedButtonTheme,
  TextSelectionThemeData? textSelectionTheme,
  DataTableThemeData? dataTableTheme,
  CheckboxThemeData? checkboxTheme,
  RadioThemeData? radioTheme,
  SwitchThemeData? switchTheme,
  bool? fixTextFieldOutlineLabel,
  @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,
}) {
  cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
  return ThemeData.raw(
    visualDensity: visualDensity ?? this.visualDensity,
    primaryColor: primaryColor ?? this.primaryColor,
    primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
    primaryColorLight: primaryColorLight ?? this.primaryColorLight,
    primaryColorDark: primaryColorDark ?? this.primaryColorDark,
    accentColor: accentColor ?? this.accentColor,
    accentColorBrightness: accentColorBrightness ?? this.accentColorBrightness,
    canvasColor: canvasColor ?? this.canvasColor,
    shadowColor: shadowColor ?? this.shadowColor,
    scaffoldBackgroundColor: scaffoldBackgroundColor ?? this.scaffoldBackgroundColor,
    bottomAppBarColor: bottomAppBarColor ?? this.bottomAppBarColor,
    cardColor: cardColor ?? this.cardColor,
    dividerColor: dividerColor ?? this.dividerColor,
    focusColor: focusColor ?? this.focusColor,
    hoverColor: hoverColor ?? this.hoverColor,
    highlightColor: highlightColor ?? this.highlightColor,
    splashColor: splashColor ?? this.splashColor,
    splashFactory: splashFactory ?? this.splashFactory,
    selectedRowColor: selectedRowColor ?? this.selectedRowColor,
    unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
    disabledColor: disabledColor ?? this.disabledColor,
    buttonColor: buttonColor ?? this.buttonColor,
    buttonTheme: buttonTheme ?? this.buttonTheme,
    toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
    secondaryHeaderColor: secondaryHeaderColor ?? this.secondaryHeaderColor,
    textSelectionColor: textSelectionColor ?? this.textSelectionColor,
    cursorColor: cursorColor ?? this.cursorColor,
    textSelectionHandleColor: textSelectionHandleColor ?? this.textSelectionHandleColor,
    backgroundColor: backgroundColor ?? this.backgroundColor,
    dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
    indicatorColor: indicatorColor ?? this.indicatorColor,
    hintColor: hintColor ?? this.hintColor,
    errorColor: errorColor ?? this.errorColor,
    toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
    textTheme: textTheme ?? this.textTheme,
    primaryTextTheme: primaryTextTheme ?? this.primaryTextTheme,
    accentTextTheme: accentTextTheme ?? this.accentTextTheme,
    inputDecorationTheme: inputDecorationTheme ?? this.inputDecorationTheme,
    iconTheme: iconTheme ?? this.iconTheme,
    primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
    accentIconTheme: accentIconTheme ?? this.accentIconTheme,
    sliderTheme: sliderTheme ?? this.sliderTheme,
    tabBarTheme: tabBarTheme ?? this.tabBarTheme,
    tooltipTheme: tooltipTheme ?? this.tooltipTheme,
    cardTheme: cardTheme ?? this.cardTheme,
    chipTheme: chipTheme ?? this.chipTheme,
    platform: platform ?? this.platform,
    materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
    applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
    pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
    appBarTheme: appBarTheme ?? this.appBarTheme,
    scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme,
    bottomAppBarTheme: bottomAppBarTheme ?? this.bottomAppBarTheme,
    colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
    dialogTheme: dialogTheme ?? this.dialogTheme,
    floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme,
    navigationRailTheme: navigationRailTheme ?? this.navigationRailTheme,
    typography: typography ?? this.typography,
    cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme,
    snackBarTheme: snackBarTheme ?? this.snackBarTheme,
    bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme,
    popupMenuTheme: popupMenuTheme ?? this.popupMenuTheme,
    bannerTheme: bannerTheme ?? this.bannerTheme,
    dividerTheme: dividerTheme ?? this.dividerTheme,
    buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
    bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
    timePickerTheme: timePickerTheme ?? this.timePickerTheme,
    textButtonTheme: textButtonTheme ?? this.textButtonTheme,
    elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
    outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
    textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
    dataTableTheme: dataTableTheme ?? this.dataTableTheme,
    checkboxTheme: checkboxTheme ?? this.checkboxTheme,
    radioTheme: radioTheme ?? this.radioTheme,
    switchTheme: switchTheme ?? this.switchTheme,
    fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
    useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme,
  );
}