copyWith method
"If the caller passes in a value for a parameter, use that value, otherwise use the value of the corresponding field."
The copyWith function is a great example of the power of Dart's optional parameters
Args: street (String): The street address of the location. city (String): city ?? this.city state (String): state ?? this.state zip (num): zip ?? this.zip,
Returns: A new Location object with the same values as the original, except for the values that were passed in.
Implementation
Location copyWith({
String? street,
String? city,
String? state,
num? zip,
}) {
return Location(
street: street ?? this.street,
city: city ?? this.city,
state: state ?? this.state,
zip: zip ?? this.zip,
);
}