mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? threadViewPost(
- UThreadViewPostParentThreadViewPost value
- TResult? notFoundPost(
- UThreadViewPostParentNotFoundPost value
- TResult? blockedPost(
- UThreadViewPostParentBlockedPost value
- TResult? unknown(
- UThreadViewPostParentUnknown 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( UThreadViewPostParentThreadViewPost value)? threadViewPost,TResult? Function( UThreadViewPostParentNotFoundPost value)? notFoundPost,TResult? Function( UThreadViewPostParentBlockedPost value)? blockedPost,TResult? Function( UThreadViewPostParentUnknown value)? unknown,}){
final _that = this;
switch (_that) {
case UThreadViewPostParentThreadViewPost() when threadViewPost != null:
return threadViewPost(_that);case UThreadViewPostParentNotFoundPost() when notFoundPost != null:
return notFoundPost(_that);case UThreadViewPostParentBlockedPost() when blockedPost != null:
return blockedPost(_that);case UThreadViewPostParentUnknown() when unknown != null:
return unknown(_that);case _:
return null;
}
}