whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? repoView(
- RepoView data
- TResult? repoViewNotFound(
- RepoViewNotFound data
- TResult? recordView(
- RecordView data
- TResult? recordViewNotFound(
- RecordViewNotFound 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( RepoView data)? repoView,TResult? Function( RepoViewNotFound data)? repoViewNotFound,TResult? Function( RecordView data)? recordView,TResult? Function( RecordViewNotFound data)? recordViewNotFound,TResult? Function( Map<String, dynamic> data)? unknown,}) {final _that = this;
switch (_that) {
case UModEventViewDetailSubjectRepoView() when repoView != null:
return repoView(_that.data);case UModEventViewDetailSubjectRepoViewNotFound() when repoViewNotFound != null:
return repoViewNotFound(_that.data);case UModEventViewDetailSubjectRecordView() when recordView != null:
return recordView(_that.data);case UModEventViewDetailSubjectRecordViewNotFound() when recordViewNotFound != null:
return recordViewNotFound(_that.data);case UModEventViewDetailSubjectUnknown() when unknown != null:
return unknown(_that.data);case _:
return null;
}
}