maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. int? id,
    2. String? nodeId,
    3. int? number,
    4. String? state,
    5. String? title,
    6. String? body,
    7. String? mergeCommitSha,
    8. String? mergeableState,
    9. String? authorAssociation,
    10. bool draft,
    11. bool merged,
    12. bool mergeable,
    13. bool rebaseable,
    14. bool maintainerCanModify,
    15. int commentsCount,
    16. int commitsCount,
    17. int additionsCount,
    18. int deletionsCount,
    19. int changedFilesCount,
    20. int reviewCommentCount,
    21. GithubRepositoryModelRef? repository,
    22. GithubUserModelRef? user,
    23. GithubUserModelRef? mergedBy,
    24. List<GithubUserModelRef?> requestedReviewers,
    25. List<GithubLabelValue> labels,
    26. GithubPullRequestHeadValue? head,
    27. GithubPullRequestHeadValue? base,
    28. GithubMilestoneValue? milestone,
    29. ModelUri? htmlUrl,
    30. ModelUri? diffUrl,
    31. ModelUri? patchUrl,
    32. ModelTimestamp? closedAt,
    33. ModelTimestamp? mergedAt,
    34. ModelTimestamp createdAt,
    35. ModelTimestamp updatedAt,
    36. bool fromServer,
    )?, {
  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(
          int? id,
          String? nodeId,
          int? number,
          String? state,
          String? title,
          String? body,
          String? mergeCommitSha,
          String? mergeableState,
          String? authorAssociation,
          bool draft,
          bool merged,
          bool mergeable,
          bool rebaseable,
          bool maintainerCanModify,
          int commentsCount,
          int commitsCount,
          int additionsCount,
          int deletionsCount,
          int changedFilesCount,
          int reviewCommentCount,
          @refParam GithubRepositoryModelRef? repository,
          @refParam GithubUserModelRef? user,
          @refParam GithubUserModelRef? mergedBy,
          @refParam List<GithubUserModelRef> requestedReviewers,
          @jsonParam List<GithubLabelValue> labels,
          @jsonParam GithubPullRequestHeadValue? head,
          @jsonParam GithubPullRequestHeadValue? base,
          @jsonParam GithubMilestoneValue? milestone,
          ModelUri? htmlUrl,
          ModelUri? diffUrl,
          ModelUri? patchUrl,
          ModelTimestamp? closedAt,
          ModelTimestamp? mergedAt,
          ModelTimestamp createdAt,
          ModelTimestamp updatedAt,
          bool fromServer)?
      $default, {
  required TResult orElse(),
}) {
  final _that = this;
  switch (_that) {
    case _GithubPullRequestModel() when $default != null:
      return $default(
          _that.id,
          _that.nodeId,
          _that.number,
          _that.state,
          _that.title,
          _that.body,
          _that.mergeCommitSha,
          _that.mergeableState,
          _that.authorAssociation,
          _that.draft,
          _that.merged,
          _that.mergeable,
          _that.rebaseable,
          _that.maintainerCanModify,
          _that.commentsCount,
          _that.commitsCount,
          _that.additionsCount,
          _that.deletionsCount,
          _that.changedFilesCount,
          _that.reviewCommentCount,
          _that.repository,
          _that.user,
          _that.mergedBy,
          _that.requestedReviewers,
          _that.labels,
          _that.head,
          _that.base,
          _that.milestone,
          _that.htmlUrl,
          _that.diffUrl,
          _that.patchUrl,
          _that.closedAt,
          _that.mergedAt,
          _that.createdAt,
          _that.updatedAt,
          _that.fromServer);
    case _:
      return orElse();
  }
}