maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
  1. TResult profileViewDetailed(
    1. ProfileViewDetailed data
    )?,
  2. TResult blockedPost(
    1. BlockedPost data
    )?,
  3. TResult generatorView(
    1. GeneratorView data
    )?,
  4. TResult notFoundPost(
    1. NotFoundPost data
    )?,
  5. TResult postView(
    1. PostView data
    )?,
  6. TResult starterPackView(
    1. StarterPackView data
    )?,
  7. TResult unknown(
    1. Map<String, dynamic> data
    )?,
  8. 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( ProfileViewDetailed data)?  profileViewDetailed,TResult Function( BlockedPost data)?  blockedPost,TResult Function( GeneratorView data)?  generatorView,TResult Function( NotFoundPost data)?  notFoundPost,TResult Function( PostView data)?  postView,TResult Function( StarterPackView data)?  starterPackView,TResult Function( Map<String, dynamic> data)?  unknown,required TResult orElse(),}) {final _that = this;
switch (_that) {
case UNotificationGetGroupedNotificationsRelatedViewsProfileViewDetailed() when profileViewDetailed != null:
return profileViewDetailed(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsBlockedPost() when blockedPost != null:
return blockedPost(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsGeneratorView() when generatorView != null:
return generatorView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsNotFoundPost() when notFoundPost != null:
return notFoundPost(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsPostView() when postView != null:
return postView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsStarterPackView() when starterPackView != null:
return starterPackView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsUnknown() when unknown != null:
return unknown(_that.data);case _:
  return orElse();

}
}