maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String title,
    2. String? titleLong,
    3. String isbn,
    4. String isbn13,
    5. String? deweyDecimal,
    6. String? binding,
    7. String? publisher,
    8. String? language,
    9. DateTime? datePublished,
    10. String? edition,
    11. int? pages,
    12. String? dimensions,
    13. String? overview,
    14. String? image,
    15. double? msrp,
    16. String? excerpt,
    17. String? synopsys,
    18. List<String?>? authors,
    19. List<String>? subjects,
    20. List<String>? reviews,
    21. List<Merchant>? prices,
    22. List<String>? related,
    )?, {
  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 title, @JsonKey(name: 'title_long')  String? titleLong,  String isbn,  String isbn13, @JsonKey(name: 'dewey_decimal')  String? deweyDecimal,  String? binding,  String? publisher,  String? language, @_DateConverter()@JsonKey(name: 'date_published')  DateTime? datePublished,  String? edition,  int? pages,  String? dimensions,  String? overview,  String? image, @_MsrpConverter()  double? msrp,  String? excerpt,  String? synopsys,  List<String?>? authors,  List<String>? subjects,  List<String>? reviews,  List<Merchant>? prices,  List<String>? related)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Book() when $default != null:
return $default(_that.title,_that.titleLong,_that.isbn,_that.isbn13,_that.deweyDecimal,_that.binding,_that.publisher,_that.language,_that.datePublished,_that.edition,_that.pages,_that.dimensions,_that.overview,_that.image,_that.msrp,_that.excerpt,_that.synopsys,_that.authors,_that.subjects,_that.reviews,_that.prices,_that.related);case _:
  return orElse();

}
}