copyWith method

  1. @override
LightPowerUpDimming copyWith({
  1. LightPowerUpDimmingMode? mode,
  2. double? brightness,
  3. bool copyOriginalValues = true,
})
override

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

copyOriginalValues is true if you want to maintain the original object's initial values. This is useful if you plan on using this object in a PUT request.

Implementation

@override
LightPowerUpDimming copyWith({
  LightPowerUpDimmingMode? mode,
  double? brightness,
  bool copyOriginalValues = true,
}) {
  LightPowerUpDimming toReturn = LightPowerUpDimming(
    mode: copyOriginalValues ? _originalMode : (mode ?? this.mode),
    brightness: copyOriginalValues
        ? originalBrightness
        : (brightness ?? this.brightness),
  );

  if (copyOriginalValues) {
    toReturn.mode = mode ?? this.mode;
    toReturn.brightness = brightness ?? this.brightness;
  }

  return toReturn;
}