mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? embedImagesView(
- UPostViewEmbedEmbedImagesView value
- TResult? embedVideoView(
- UPostViewEmbedEmbedVideoView value
- TResult? embedExternalView(
- UPostViewEmbedEmbedExternalView value
- TResult? embedRecordView(
- UPostViewEmbedEmbedRecordView value
- TResult? embedRecordWithMediaView(
- UPostViewEmbedEmbedRecordWithMediaView value
- TResult? unknown(
- UPostViewEmbedUnknown value
A variant of map
that fallback to returning null
.
It is equivalent to doing:
switch (sealedClass) {
case final Subclass value:
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( UPostViewEmbedEmbedImagesView value)? embedImagesView,TResult? Function( UPostViewEmbedEmbedVideoView value)? embedVideoView,TResult? Function( UPostViewEmbedEmbedExternalView value)? embedExternalView,TResult? Function( UPostViewEmbedEmbedRecordView value)? embedRecordView,TResult? Function( UPostViewEmbedEmbedRecordWithMediaView value)? embedRecordWithMediaView,TResult? Function( UPostViewEmbedUnknown value)? unknown,}){
final _that = this;
switch (_that) {
case UPostViewEmbedEmbedImagesView() when embedImagesView != null:
return embedImagesView(_that);case UPostViewEmbedEmbedVideoView() when embedVideoView != null:
return embedVideoView(_that);case UPostViewEmbedEmbedExternalView() when embedExternalView != null:
return embedExternalView(_that);case UPostViewEmbedEmbedRecordView() when embedRecordView != null:
return embedRecordView(_that);case UPostViewEmbedEmbedRecordWithMediaView() when embedRecordWithMediaView != null:
return embedRecordWithMediaView(_that);case UPostViewEmbedUnknown() when unknown != null:
return unknown(_that);case _:
return null;
}
}