whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? repoRef(
- RepoRef data
- TResult? repoStrongRef(
- RepoStrongRef data
- TResult? messageRef(
- MessageRef data
- TResult? unknown()?,
A variant of when
that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function( RepoRef data)? repoRef,TResult? Function( RepoStrongRef data)? repoStrongRef,TResult? Function( MessageRef data)? messageRef,TResult? Function( Map<String, dynamic> data)? unknown,}) {final _that = this;
switch (_that) {
case UModEventViewSubjectRepoRef() when repoRef != null:
return repoRef(_that.data);case UModEventViewSubjectRepoStrongRef() when repoStrongRef != null:
return repoStrongRef(_that.data);case UModEventViewSubjectMessageRef() when messageRef != null:
return messageRef(_that.data);case UModEventViewSubjectUnknown() when unknown != null:
return unknown(_that.data);case _:
return null;
}
}