when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. AtUri uri,
    3. String cid,
    4. String did,
    5. ProfileView creator,
    6. String displayName,
    7. String? description,
    8. List<RichtextFacet>? descriptionFacets,
    9. String? avatar,
    10. int? likeCount,
    11. bool? acceptsInteractions,
    12. List<Label>? labels,
    13. GeneratorViewerState? viewer,
    14. GeneratorViewContentMode? contentMode,
    15. DateTime indexedAt,
    16. Map<String, dynamic>? $unknown,
    )
)

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?>(TResult Function( String $type, @AtUriConverter()  AtUri uri,  String cid,  String did, @ProfileViewConverter()  ProfileView creator,  String displayName,  String? description, @RichtextFacetConverter()  List<RichtextFacet>? descriptionFacets,  String? avatar,  int? likeCount,  bool? acceptsInteractions, @LabelConverter()  List<Label>? labels, @GeneratorViewerStateConverter()  GeneratorViewerState? viewer, @GeneratorViewContentModeConverter()  GeneratorViewContentMode? contentMode,  DateTime indexedAt,  Map<String, dynamic>? $unknown)  $default,) {final _that = this;
switch (_that) {
case _GeneratorView():
return $default(_that.$type,_that.uri,_that.cid,_that.did,_that.creator,_that.displayName,_that.description,_that.descriptionFacets,_that.avatar,_that.likeCount,_that.acceptsInteractions,_that.labels,_that.viewer,_that.contentMode,_that.indexedAt,_that.$unknown);case _:
  throw StateError('Unexpected subclass');

}
}