copyWith method
The copyWith function in Dart creates a new Port object with updated properties.
Args:
position (Offset): The position parameter in the copyWith method is an optional parameter of
type Offset. It is used to specify the new position for the Port object being copied. If a new
position is provided, it will be used in the copied Port object; otherwise, the
Returns:
A new instance of the Port class is being returned with the specified properties copied from
the current instance, and the position property updated with the provided value or the current
value if no new value is provided.
Implementation
Port copyWith({Offset? position}) {
return Port(
id: id,
maxLinks: maxLinks,
label: label,
position: position ?? this.position,
);
}