maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult profileViewBasic(
- ProfileViewBasic data
- TResult profileView(
- ProfileView data
- TResult profileViewDetailed(
- ProfileViewDetailed data
- required TResult orElse(),
A variant of when
that fallback to an orElse
callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function( ProfileViewBasic data)? profileViewBasic,TResult Function( ProfileView data)? profileView,TResult Function( ProfileViewDetailed data)? profileViewDetailed,required TResult orElse(),}) {final _that = this;
switch (_that) {
case UModerationSubjectProfileProfileViewBasic() when profileViewBasic != null:
return profileViewBasic(_that.data);case UModerationSubjectProfileProfileView() when profileView != null:
return profileView(_that.data);case UModerationSubjectProfileProfileViewDetailed() when profileViewDetailed != null:
return profileViewDetailed(_that.data);case _:
return orElse();
}
}