whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- String $type,
- AtUri uri,
- String cid,
- ProfileViewBasic author,
- Map<
String, dynamic> record, - UPostViewEmbed? embed,
- int? bookmarkCount,
- int? replyCount,
- int? repostCount,
- int? likeCount,
- int? quoteCount,
- DateTime indexedAt,
- ViewerState? viewer,
- List<
Label> ? labels, - ThreadgateView? threadgate,
- Map<
String, dynamic> ? $unknown,
A variant of when
that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String $type, @AtUriConverter() AtUri uri, String cid, @ProfileViewBasicConverter() ProfileViewBasic author, Map<String, dynamic> record, @UPostViewEmbedConverter() UPostViewEmbed? embed, int? bookmarkCount, int? replyCount, int? repostCount, int? likeCount, int? quoteCount, DateTime indexedAt, @ViewerStateConverter() ViewerState? viewer, @LabelConverter() List<Label>? labels, @ThreadgateViewConverter() ThreadgateView? threadgate, Map<String, dynamic>? $unknown)? $default,) {final _that = this;
switch (_that) {
case _PostView() when $default != null:
return $default(_that.$type,_that.uri,_that.cid,_that.author,_that.record,_that.embed,_that.bookmarkCount,_that.replyCount,_that.repostCount,_that.likeCount,_that.quoteCount,_that.indexedAt,_that.viewer,_that.labels,_that.threadgate,_that.$unknown);case _:
return null;
}
}