copyWith method
Creates a copy of this object with the given fields replaced with the new values.
For nullable fields, passing null leaves the field unchanged (standard
Dart copyWith behavior). To explicitly reset a nullable field to
null, pass a domain-invalid sentinel value:
String?fields: pass an empty string (isEmpty) to reset tonull.List?/Set?fields: pass an empty collection (isEmpty) to reset tonull.double?/int?fields (positive-only, e.g. height/width/angle): pass a negative value (isNegative) to reset tonull.
These sentinel values are never valid for the respective fields (enforced by constructor assertions), making the intent unambiguous.
mainColor: The primary color of the element.shape: The shape of the element.offset: The offset position of the element.heightFactor: The height factor of the element.widthFactor: The width factor of the element. Pass a negative value to reset tonull.angle: The rotation angle of the element in degrees. Pass a negative value to reset tonull.child: A potential child element.
Implementation
ElementsProperties copyWith({
Color? mainColor,
Shape? shape,
Offset? offset,
double? heightFactor,
double? widthFactor,
int? angle,
ElementsProperties? child,
}) => ElementsProperties(
mainColor ?? this.mainColor,
shape: shape ?? this.shape,
offset: offset ?? this.offset,
heightFactor: heightFactor ?? this.heightFactor,
widthFactor: (widthFactor?.isNegative ?? false)
? null
: (widthFactor ?? this.widthFactor),
angle: (angle?.isNegative ?? false) ? null : (angle ?? this.angle),
child: child ?? this.child,
);