whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? repoRef(
- RepoRef data
- TResult? repoStrongRef(
- RepoStrongRef data
- TResult? repoBlobRef(
- RepoBlobRef 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( RepoBlobRef data)? repoBlobRef,TResult? Function( Map<String, dynamic> data)? unknown,}) {final _that = this;
switch (_that) {
case UAdminGetSubjectStatusSubjectRepoRef() when repoRef != null:
return repoRef(_that.data);case UAdminGetSubjectStatusSubjectRepoStrongRef() when repoStrongRef != null:
return repoStrongRef(_that.data);case UAdminGetSubjectStatusSubjectRepoBlobRef() when repoBlobRef != null:
return repoBlobRef(_that.data);case UAdminGetSubjectStatusSubjectUnknown() when unknown != null:
return unknown(_that.data);case _:
return null;
}
}