maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default(
- String title,
- String? titleLong,
- String isbn,
- String isbn13,
- String? deweyDecimal,
- String? binding,
- String? publisher,
- String? language,
- DateTime? datePublished,
- String? edition,
- int? pages,
- String? dimensions,
- String? overview,
- String? image,
- double? msrp,
- String? excerpt,
- String? synopsys,
- List<
String?> ? authors, - List<
String> ? subjects, - List<
String> ? reviews, - List<
Merchant> ? prices,
- 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();
}
}