maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. String $type,
    2. String did,
    3. String handle,
    4. String? displayName,
    5. String? description,
    6. String? pronouns,
    7. String? avatar,
    8. String? banner,
    9. int? followersCount,
    10. int? followsCount,
    11. int? postsCount,
    12. @ProfileAssociatedConverter() ProfileAssociated? associated,
    13. @StarterPackViewBasicConverter() StarterPackViewBasic? joinedViaStarterPack,
    14. @JsonKey.new(toJson: iso8601) DateTime? indexedAt,
    15. @JsonKey.new(toJson: iso8601) DateTime? createdAt,
    16. @ViewerStateConverter() ViewerState? viewer,
    17. @LabelConverter() List<Label>? labels,
    18. @RepoStrongRefConverter() RepoStrongRef? pinnedPost,
    19. @ProfileLinkViewConverter() List<ProfileLinkView>? links,
    20. @VerificationStateConverter() VerificationState? verification,
    21. @StatusViewConverter() StatusView? status,
    22. Map<String, dynamic>? debug,
    23. Map<String, dynamic>? $unknown,
    )?, {
  2. 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( String $type,  String did,  String handle,  String? displayName,  String? description,  String? pronouns,  String? avatar,  String? banner,  int? followersCount,  int? followsCount,  int? postsCount, @ProfileAssociatedConverter()  ProfileAssociated? associated, @StarterPackViewBasicConverter()  StarterPackViewBasic? joinedViaStarterPack, @JsonKey(toJson: iso8601)  DateTime? indexedAt, @JsonKey(toJson: iso8601)  DateTime? createdAt, @ViewerStateConverter()  ViewerState? viewer, @LabelConverter()  List<Label>? labels, @RepoStrongRefConverter()  RepoStrongRef? pinnedPost, @ProfileLinkViewConverter()  List<ProfileLinkView>? links, @VerificationStateConverter()  VerificationState? verification, @StatusViewConverter()  StatusView? status,  Map<String, dynamic>? debug,  Map<String, dynamic>? $unknown)?  $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _ProfileViewDetailed() when $default != null:
return $default(_that.$type,_that.did,_that.handle,_that.displayName,_that.description,_that.pronouns,_that.avatar,_that.banner,_that.followersCount,_that.followsCount,_that.postsCount,_that.associated,_that.joinedViaStarterPack,_that.indexedAt,_that.createdAt,_that.viewer,_that.labels,_that.pinnedPost,_that.links,_that.verification,_that.status,_that.debug,_that.$unknown);case _:
  return orElse();

}
}