maybeMap<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
  1. TResult repoRef(
    1. UModEventViewSubjectRepoRef value
    )?,
  2. TResult repoStrongRef(
    1. UModEventViewSubjectRepoStrongRef value
    )?,
  3. TResult messageRef(
    1. UModEventViewSubjectMessageRef value
    )?,
  4. TResult convoRef(
    1. UModEventViewSubjectConvoRef value
    )?,
  5. TResult unknown(
    1. UModEventViewSubjectUnknown value
    )?,
  6. required TResult orElse(),
})

A variant of map that fallback to returning orElse.

It is equivalent to doing:

switch (sealedClass) {
  case final Subclass value:
    return ...;
  case _:
    return orElse();
}

Implementation

@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( UModEventViewSubjectRepoRef value)?  repoRef,TResult Function( UModEventViewSubjectRepoStrongRef value)?  repoStrongRef,TResult Function( UModEventViewSubjectMessageRef value)?  messageRef,TResult Function( UModEventViewSubjectConvoRef value)?  convoRef,TResult Function( UModEventViewSubjectUnknown value)?  unknown,required TResult orElse(),}){
final _that = this;
switch (_that) {
case UModEventViewSubjectRepoRef() when repoRef != null:
return repoRef(_that);case UModEventViewSubjectRepoStrongRef() when repoStrongRef != null:
return repoStrongRef(_that);case UModEventViewSubjectMessageRef() when messageRef != null:
return messageRef(_that);case UModEventViewSubjectConvoRef() when convoRef != null:
return convoRef(_that);case UModEventViewSubjectUnknown() when unknown != null:
return unknown(_that);case _:
  return orElse();

}
}