copyWith method
Creates a new Rgb color instance by copying the current instance and optionally updating its properties.
The method returns a new Rgb instance based on the current instance,
with optional property updates. If any of the properties (r
, g
, b
,
opacity
) are provided, they will be used to create the new instance. If
a property is not provided, the value from the current instance is used.
Example:
final originalColor = Rgb(255, 0, 0, 1.0);
final updatedColor = originalColor.copyWith(g: 128, opacity: 0.5);
Returns a new Rgb instance with the updated properties.
Implementation
Rgb copyWith({num? r, num? g, num? b, num? opacity}) =>
Rgb(r ?? this.r, g ?? this.g, b ?? this.b, opacity ?? this.opacity);