when<TResult extends Object?> method
- @optionalTypeArgs
- required TResult mentionRule(
- MentionRule data
- required TResult followerRule(
- FollowerRule data
- required TResult followingRule(
- FollowingRule data
- required TResult listRule(
- ListRule data
- required TResult unknown(),
A switch
-like method, using callbacks.
As opposed to map
, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( MentionRule data) mentionRule,required TResult Function( FollowerRule data) followerRule,required TResult Function( FollowingRule data) followingRule,required TResult Function( ListRule data) listRule,required TResult Function( Map<String, dynamic> data) unknown,}) {final _that = this;
switch (_that) {
case UPostInteractionSettingsPrefThreadgateAllowRulesMentionRule():
return mentionRule(_that.data);case UPostInteractionSettingsPrefThreadgateAllowRulesFollowerRule():
return followerRule(_that.data);case UPostInteractionSettingsPrefThreadgateAllowRulesFollowingRule():
return followingRule(_that.data);case UPostInteractionSettingsPrefThreadgateAllowRulesListRule():
return listRule(_that.data);case UPostInteractionSettingsPrefThreadgateAllowRulesUnknown():
return unknown(_that.data);}
}