mapOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? mentionRule(
- UDraftThreadgateAllowMentionRule value
- TResult? followerRule(
- UDraftThreadgateAllowFollowerRule value
- TResult? followingRule(
- UDraftThreadgateAllowFollowingRule value
- TResult? listRule(
- UDraftThreadgateAllowListRule value
- TResult? unknown(
- UDraftThreadgateAllowUnknown 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( UDraftThreadgateAllowMentionRule value)? mentionRule,TResult? Function( UDraftThreadgateAllowFollowerRule value)? followerRule,TResult? Function( UDraftThreadgateAllowFollowingRule value)? followingRule,TResult? Function( UDraftThreadgateAllowListRule value)? listRule,TResult? Function( UDraftThreadgateAllowUnknown value)? unknown,}){
final _that = this;
switch (_that) {
case UDraftThreadgateAllowMentionRule() when mentionRule != null:
return mentionRule(_that);case UDraftThreadgateAllowFollowerRule() when followerRule != null:
return followerRule(_that);case UDraftThreadgateAllowFollowingRule() when followingRule != null:
return followingRule(_that);case UDraftThreadgateAllowListRule() when listRule != null:
return listRule(_that);case UDraftThreadgateAllowUnknown() when unknown != null:
return unknown(_that);case _:
return null;
}
}