copyWith method

Name copyWith({
  1. String? title,
  2. String? first,
  3. String? last,
})

If any of the parameters are passed in, use them, otherwise use the current value.

Args: title (String): The title of the person. first (String): The first name of the user. last (String): last ?? this.last,

Returns: A new instance of the Name class with the updated values.

Implementation

Name copyWith({
  String? title,
  String? first,
  String? last,
}) {
  return Name(
    title: title ?? this.title,
    first: first ?? this.first,
    last: last ?? this.last,
  );
}