maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String id,
    2. @JsonKey.new(defaultValue: '') String address1,
    3. @JsonKey.new(defaultValue: '') String city,
    4. @JsonKey.new(defaultValue: '') String country,
    5. String? zip,
    6. String? lastName,
    7. String? name,
    8. String? firstName,
    9. String? address2,
    10. String? company,
    11. String? countryCodeV2,
    12. String? formattedArea,
    13. double? latitude,
    14. double? longitude,
    15. String? phone,
    16. String? province,
    17. String? provinceCode,
    )?, {
  2. required TResult orElse(),
})

A variant of when that fallback to an orElse callback.

It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, @JsonKey(defaultValue: '')  String address1, @JsonKey(defaultValue: '')  String city, @JsonKey(defaultValue: '')  String country,  String? zip,  String? lastName,  String? name,  String? firstName,  String? address2,  String? company,  String? countryCodeV2,  String? formattedArea,  double? latitude,  double? longitude,  String? phone,  String? province,  String? provinceCode)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _MailingAddress() when $default != null:
return $default(_that.id,_that.address1,_that.city,_that.country,_that.zip,_that.lastName,_that.name,_that.firstName,_that.address2,_that.company,_that.countryCodeV2,_that.formattedArea,_that.latitude,_that.longitude,_that.phone,_that.province,_that.provinceCode);case _:
  return orElse();

}
}