copyWith method

ThemeData copyWith({
  1. ValueGetter<ColorScheme>? colorScheme,
  2. ValueGetter<double>? radius,
  3. ValueGetter<Typography>? typography,
  4. ValueGetter<TargetPlatform>? platform,
  5. ValueGetter<double>? scaling,
  6. ValueGetter<IconThemeProperties>? iconTheme,
  7. ValueGetter<double>? surfaceOpacity,
  8. ValueGetter<double>? surfaceBlur,
  9. ValueGetter<bool?>? enableFeedback,
  10. ValueGetter<Density>? density,
})

Creates a copy of this theme with specified properties overridden.

All parameters are optional getters that provide new values when present.

Returns: ThemeData — a new theme with updated values.

Implementation

ThemeData copyWith({
  ValueGetter<ColorScheme>? colorScheme,
  ValueGetter<double>? radius,
  ValueGetter<Typography>? typography,
  ValueGetter<TargetPlatform>? platform,
  ValueGetter<double>? scaling,
  ValueGetter<IconThemeProperties>? iconTheme,
  ValueGetter<double>? surfaceOpacity,
  ValueGetter<double>? surfaceBlur,
  ValueGetter<bool?>? enableFeedback,
  ValueGetter<Density>? density,
}) {
  return ThemeData(
    colorScheme: colorScheme == null ? this.colorScheme : colorScheme(),
    radius: radius == null ? this.radius : radius(),
    typography: typography == null ? this.typography : typography(),
    platform: platform == null ? _platform : platform(),
    scaling: scaling == null ? this.scaling : scaling(),
    iconTheme: iconTheme == null ? this.iconTheme : iconTheme(),
    surfaceOpacity:
        surfaceOpacity == null ? this.surfaceOpacity : surfaceOpacity(),
    surfaceBlur: surfaceBlur == null ? this.surfaceBlur : surfaceBlur(),
    enableFeedback:
        enableFeedback == null ? this.enableFeedback : enableFeedback(),
    density: density == null ? this.density : density(),
  );
}