copyWith method

CustomElementsProperties copyWith({
  1. Color? mainColor,
  2. List<Color>? otherColors,
  3. Offset? offset,
  4. double? heightFactor,
  5. double? widthFactor,
  6. int? angle,
})

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.
  • otherColors: A list of additional colors for 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.

Implementation

CustomElementsProperties copyWith({
  Color? mainColor,
  List<Color>? otherColors,
  Offset? offset,
  double? heightFactor,
  double? widthFactor,
  int? angle,
}) => CustomElementsProperties(
  mainColor ?? this.mainColor,
  otherColors: otherColors ?? this.otherColors,
  offset: offset ?? this.offset,
  heightFactor: heightFactor ?? this.heightFactor,
  widthFactor: (widthFactor?.isNegative ?? false)
      ? null
      : (widthFactor ?? this.widthFactor),
  angle: (angle?.isNegative ?? false) ? null : (angle ?? this.angle),
);