copyWith method

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

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

@override

/// Creates a copy of this theme but with the given fields replaced with the new values.
///
/// The [brightness] value is applied to the [colorScheme].
GBThemeData copyWith({
  Color? accentColor,
  Color? accentError,
  Color? accentErrorLight,
  Color? backgroundBase,
  Color? backgroundContrast,
  Color? backgroundDisabled,
  Color? backgroundFocus,
  Color? textBase,
  Color? textBlack,
  Color? textDisabled,
  Color? textWhite,
  BorderRadius? textFieldRadius,
  double? textFieldBorderWidth,
  BorderRadius? buttonsRadius,
  ContainedButtonThemeData? containedButtonThemeData,
  /* Default Theme */
  // GENERAL CONFIGURATION
  Iterable<Adaptation<Object>>? adaptations,
  bool? applyElevationOverlayColor,
  NoDefaultCupertinoThemeData? cupertinoOverrideTheme,
  Iterable<ThemeExtension<dynamic>>? extensions,
  Object? 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? disabledColor,
  Color? dividerColor,
  Color? focusColor,
  Color? highlightColor,
  Color? hintColor,
  Color? hoverColor,
  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,
  // TODO(huycozy): Change the parameter type to AppBarThemeData
  Object? appBarTheme,
  BadgeThemeData? badgeTheme,
  MaterialBannerThemeData? bannerTheme,
  BottomAppBarThemeData? bottomAppBarTheme,
  BottomNavigationBarThemeData? bottomNavigationBarTheme,
  BottomSheetThemeData? bottomSheetTheme,
  ButtonThemeData? buttonTheme,
  CardThemeData? cardTheme,
  CarouselViewThemeData? carouselViewTheme,
  CheckboxThemeData? checkboxTheme,
  ChipThemeData? chipTheme,
  DataTableThemeData? dataTableTheme,
  DatePickerThemeData? datePickerTheme,
  DialogThemeData? 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,
  TabBarThemeData? 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,
  @Deprecated(
    'Use DialogThemeData.backgroundColor instead. '
    'This feature was deprecated after v3.27.0-0.1.pre.',
  )
  Color? dialogBackgroundColor,
  @Deprecated(
    'Use TabBarThemeData.indicatorColor instead. '
    'This feature was deprecated after v3.28.0-1.0.pre.',
  )
  Color? indicatorColor,
}) {
  cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault() as CupertinoThemeData?;
  // TODO(bleroux): Clean this up once the type of `inputDecorationTheme` is changed to `InputDecorationThemeData`
  if (inputDecorationTheme != null) {
    if (inputDecorationTheme is InputDecorationTheme) {
      inputDecorationTheme = inputDecorationTheme.data;
    } else if (inputDecorationTheme is! InputDecorationThemeData) {
      throw ArgumentError(
        'inputDecorationTheme must be either a InputDecorationThemeData or a InputDecorationTheme',
      );
    }
  }
  return GBThemeData.raw(
    accentColor: accentColor ?? this.accentColor,
    accentError: accentError ?? this.accentError,
    accentErrorLight: accentErrorLight ?? this.accentErrorLight,
    backgroundBase: backgroundBase ?? this.backgroundBase,
    backgroundContrast: backgroundContrast ?? this.backgroundContrast,
    backgroundDisabled: backgroundDisabled ?? this.backgroundDisabled,
    backgroundFocus: backgroundFocus ?? this.backgroundFocus,
    textBase: textBase ?? this.textBase,
    textBlack: textBlack ?? this.textBlack,
    textDisabled: textDisabled ?? this.textDisabled,
    textWhite: textWhite ?? this.textWhite,
    textFieldRadius: textFieldRadius ?? this.textFieldRadius,
    buttonsRadius: buttonsRadius ?? this.buttonsRadius,
    textFieldBorderWidth: textFieldBorderWidth ?? this.textFieldBorderWidth,
    // containedButtonTheme: containedButtonThemeData ?? this.containedButtonTheme,
    containedButtonTheme: _containedButtonTheme(
      (containedButtonThemeData ?? this.containedButtonTheme),
      accentColor: accentColor ?? this.colorScheme.secondary,
      backgroundDisabled: backgroundDisabled ?? this.backgroundDisabled,
      buttonsRadius: buttonsRadius,
    ),

    /* DefaultTheme */
    // GENERAL CONFIGURATION
    adaptationMap: adaptations != null ? _createAdaptationMap(adaptations) : adaptationMap,
    applyElevationOverlayColor: applyElevationOverlayColor ?? this.applyElevationOverlayColor,
    cupertinoOverrideTheme: cupertinoOverrideTheme ?? this.cupertinoOverrideTheme,
    extensions: (extensions != null) ? _themeExtensionIterableToMap(extensions) : this.extensions,
    inputDecorationTheme: _getInputDecorationTheme(
      inputDecorationTheme as GBInputDecorationTheme? ?? this.inputDecorationTheme,
      accentColor: accentColor ?? this.colorScheme.secondary,
      accentError: accentError ?? this.accentError,
      accentErrorLight: accentErrorLight ?? this.accentErrorLight,
      backgroundBase: backgroundBase ?? this.backgroundBase,
      backgroundContrast: backgroundContrast ?? this.backgroundContrast,
      backgroundDisabled: backgroundDisabled ?? this.disabledColor,
      backgroundFocus: backgroundFocus ?? this.backgroundFocus,
      primaryColor: primaryColor ?? this.primaryColor,
      textBase: textBase ?? this.textBase,
      textBlack: textBlack ?? this.textBlack,
      textDisabled: textDisabled ?? this.textDisabled,
      textWhite: textWhite ?? this.textWhite,
      textFieldRadius: textFieldRadius ?? this.textFieldRadius,
      textFieldBorderWidth: textFieldBorderWidth ?? this.textFieldBorderWidth,
    ),
    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),
    disabledColor: disabledColor ?? this.disabledColor,
    dividerColor: dividerColor ?? this.dividerColor,
    focusColor: focusColor ?? this.focusColor,
    highlightColor: highlightColor ?? this.highlightColor,
    hintColor: hintColor ?? this.hintColor,
    hoverColor: hoverColor ?? this.hoverColor,
    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,
    // TODO(huycozy): Remove this check when appBarTheme is a AppBarThemeData
    appBarTheme: () {
      if (appBarTheme != null) {
        if (appBarTheme is AppBarTheme) {
          return appBarTheme.data;
        } else if (appBarTheme is! AppBarThemeData) {
          throw ArgumentError('appBarTheme must be either a AppBarThemeData or a AppBarTheme');
        }
      }
      return appBarTheme as AppBarThemeData? ?? 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,
    carouselViewTheme: carouselViewTheme ?? this.carouselViewTheme,
    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)
    buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme,
    dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
    indicatorColor: indicatorColor ?? this.indicatorColor,
  );
}