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