copyWith method

Wave copyWith({
  1. WaveDirection? direction,
  2. WaveGravityDirection? gravityDirection,
  3. double? amplitude,
  4. int? frequency,
  5. double? phase,
  6. double? offset,
  7. bool? useScaledOffset,
  8. Color? color,
  9. Color? lineColor = _sentinelValue,
  10. double? lineThickness,
})

Returns a copy of this object with its field values replaced by the ones provided to this method.

Since lineColor is nullable, it is defaulted to an empty object in this method. If left as an empty object, its current value in this Wave object will be used. This way, if it is null, the program will know that it is intentionally being set to null.

Implementation

Wave copyWith({
  WaveDirection? direction,
  WaveGravityDirection? gravityDirection,
  double? amplitude,
  int? frequency,
  double? phase,
  double? offset,
  bool? useScaledOffset,
  Color? color,
  Color? lineColor = _sentinelValue,
  double? lineThickness,
}) {
  return Wave(
    direction: direction ?? this.direction,
    gravityDirection: gravityDirection ?? this.gravityDirection,
    amplitude: amplitude ?? this.amplitude,
    frequency: frequency ?? this.frequency,
    phase: phase ?? this.phase,
    offset: offset ?? this.offset,
    useScaledOffset: useScaledOffset ?? this.useScaledOffset,
    color: color ?? this.color,
    lineColor:
        identical(lineColor, _sentinelValue) ? this.lineColor : lineColor,
    lineThickness: lineThickness ?? this.lineThickness,
  );
}