map<TResult extends Object?> method

  1. @optionalTypeArgs
TResult map<TResult extends Object?>({
  1. required TResult threadViewPost(
    1. UThreadViewPostParentThreadViewPost value
    ),
  2. required TResult notFoundPost(
    1. UThreadViewPostParentNotFoundPost value
    ),
  3. required TResult blockedPost(
    1. UThreadViewPostParentBlockedPost value
    ),
  4. required TResult unknown(
    1. UThreadViewPostParentUnknown value
    ),
})

A switch-like method, using callbacks.

Callbacks receives the raw object, upcasted. It is equivalent to doing:

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

Implementation

@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( UThreadViewPostParentThreadViewPost value)  threadViewPost,required TResult Function( UThreadViewPostParentNotFoundPost value)  notFoundPost,required TResult Function( UThreadViewPostParentBlockedPost value)  blockedPost,required TResult Function( UThreadViewPostParentUnknown value)  unknown,}){
final _that = this;
switch (_that) {
case UThreadViewPostParentThreadViewPost():
return threadViewPost(_that);case UThreadViewPostParentNotFoundPost():
return notFoundPost(_that);case UThreadViewPostParentBlockedPost():
return blockedPost(_that);case UThreadViewPostParentUnknown():
return unknown(_that);}
}