copyWith method

SceneMetadata copyWith({
  1. String? name,
  2. Relative? image,
  3. bool copyOriginalValues = true,
})

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

SceneMetadata copyWith({
  String? name,
  Relative? image,
  bool copyOriginalValues = true,
}) {
  SceneMetadata toReturn = SceneMetadata(
    name: copyOriginalValues ? _originalName : (name ?? this.name),
    image:
        image ?? this.image.copyWith(copyOriginalValues: copyOriginalValues),
  );

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

  return toReturn;
}