when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>({
  1. required TResult profileViewDetailed(
    1. ProfileViewDetailed data
    ),
  2. required TResult blockedPost(
    1. BlockedPost data
    ),
  3. required TResult generatorView(
    1. GeneratorView data
    ),
  4. required TResult notFoundPost(
    1. NotFoundPost data
    ),
  5. required TResult postView(
    1. PostView data
    ),
  6. required TResult starterPackView(
    1. StarterPackView data
    ),
  7. required TResult unknown(
    1. Map<String, dynamic> data
    ),
})

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( ProfileViewDetailed data)  profileViewDetailed,required TResult Function( BlockedPost data)  blockedPost,required TResult Function( GeneratorView data)  generatorView,required TResult Function( NotFoundPost data)  notFoundPost,required TResult Function( PostView data)  postView,required TResult Function( StarterPackView data)  starterPackView,required TResult Function( Map<String, dynamic> data)  unknown,}) {final _that = this;
switch (_that) {
case UNotificationGetGroupedNotificationsRelatedViewsProfileViewDetailed():
return profileViewDetailed(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsBlockedPost():
return blockedPost(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsGeneratorView():
return generatorView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsNotFoundPost():
return notFoundPost(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsPostView():
return postView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsStarterPackView():
return starterPackView(_that.data);case UNotificationGetGroupedNotificationsRelatedViewsUnknown():
return unknown(_that.data);}
}