maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
  1. TResult repoView(
    1. RepoView data
    )?,
  2. TResult repoViewNotFound(
    1. RepoViewNotFound data
    )?,
  3. TResult recordView(
    1. RecordView data
    )?,
  4. TResult recordViewNotFound(
    1. RecordViewNotFound data
    )?,
  5. TResult convoView(
    1. ConvoView data
    )?,
  6. TResult unknown(
    1. Map<String, dynamic> data
    )?,
  7. 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( RepoView data)?  repoView,TResult Function( RepoViewNotFound data)?  repoViewNotFound,TResult Function( RecordView data)?  recordView,TResult Function( RecordViewNotFound data)?  recordViewNotFound,TResult Function( ConvoView data)?  convoView,TResult Function( Map<String, dynamic> data)?  unknown,required TResult orElse(),}) {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 UModEventViewDetailSubjectConvoView() when convoView != null:
return convoView(_that.data);case UModEventViewDetailSubjectUnknown() when unknown != null:
return unknown(_that.data);case _:
  return orElse();

}
}