copyWith method Null safety

ColorScheme copyWith(
  1. {Color? primary,
  2. Color? primaryVariant,
  3. Color? secondary,
  4. Color? secondaryVariant,
  5. Color? surface,
  6. Color? background,
  7. Color? error,
  8. Color? onPrimary,
  9. Color? onSecondary,
  10. Color? onSurface,
  11. Color? onBackground,
  12. Color? onError,
  13. Brightness? brightness}
)

Creates a copy of this color scheme with the given fields replaced by the non-null parameter values.

Implementation

ColorScheme copyWith({
  Color? primary,
  Color? primaryVariant,
  Color? secondary,
  Color? secondaryVariant,
  Color? surface,
  Color? background,
  Color? error,
  Color? onPrimary,
  Color? onSecondary,
  Color? onSurface,
  Color? onBackground,
  Color? onError,
  Brightness? brightness,
}) {
  return ColorScheme(
    primary: primary ?? this.primary,
    primaryVariant: primaryVariant ?? this.primaryVariant,
    secondary: secondary ?? this.secondary,
    secondaryVariant: secondaryVariant ?? this.secondaryVariant,
    surface: surface ?? this.surface,
    background: background ?? this.background,
    error: error ?? this.error,
    onPrimary: onPrimary ?? this.onPrimary,
    onSecondary: onSecondary ?? this.onSecondary,
    onSurface: onSurface ?? this.onSurface,
    onBackground: onBackground ?? this.onBackground,
    onError: onError ?? this.onError,
    brightness: brightness ?? this.brightness,
  );
}