copyWith method

ElementsProperties copyWith({
  1. Color? mainColor,
  2. Shape? shape,
  3. Offset? offset,
  4. double? heightFactor,
  5. double? widthFactor,
  6. int? angle,
  7. ElementsProperties? child,
})

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 to null.
  • List? / Set? fields: pass an empty collection (isEmpty) to reset to null.
  • double?/int? fields (positive-only, e.g. height/width/angle): pass a negative value (isNegative) to reset to null.

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 to null.
  • angle: The rotation angle of the element in degrees. Pass a negative value to reset to null.
  • 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,
);