mapOrNull<TResult extends Object?> method

  1. @optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
  1. TResult? mentionRule(
    1. UPostInteractionSettingsPrefThreadgateAllowRulesMentionRule value
    )?,
  2. TResult? followerRule(
    1. UPostInteractionSettingsPrefThreadgateAllowRulesFollowerRule value
    )?,
  3. TResult? followingRule(
    1. UPostInteractionSettingsPrefThreadgateAllowRulesFollowingRule value
    )?,
  4. TResult? listRule(
    1. UPostInteractionSettingsPrefThreadgateAllowRulesListRule value
    )?,
  5. TResult? unknown(
    1. 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;

}
}