maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default()?, {
- 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( AuthorV2? author, List<Comment>? commentList, String? content, String? contentHtml, String? excerpt, String? excerptHtml, String? handle, String? id, ShopifyImage? image, String? publishedAt, List<String>? tags, String? title, String? onlineStoreUrl)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Article() when $default != null:
return $default(_that.author,_that.commentList,_that.content,_that.contentHtml,_that.excerpt,_that.excerptHtml,_that.handle,_that.id,_that.image,_that.publishedAt,_that.tags,_that.title,_that.onlineStoreUrl);case _:
return orElse();
}
}