maybeWhen<TResult extends Object?> method

  1. @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
  1. TResult $default(
    1. int? id,
    2. String? body,
    3. String? previousBody,
    4. String? diffHunk,
    5. String? path,
    6. int? position,
    7. int? originalPosition,
    8. String? commitId,
    9. String? originalCommitId,
    10. String? sha,
    11. String? state,
    12. int? reviewId,
    13. GithubTimelineEvent event,
    14. @jsonParam GithubUserModel? user,
    15. @jsonParam GithubUserModel? from,
    16. @jsonParam GithubUserModel? to,
    17. @jsonParam GithubProjectModel? project,
    18. @jsonParam GithubMilestoneValue? milestone,
    19. @jsonParam GithubReactionValue? reaction,
    20. @jsonParam GithubIssueModel? issue,
    21. @jsonParam GithubPullRequestModel? pullRequest,
    22. @jsonParam GithubLabelValue? label,
    23. ModelUri? url,
    24. ModelUri? pullRequestUrl,
    25. ModelUri? commitUrl,
    26. ModelUri? links,
    27. ModelUri? issueUrl,
    28. ModelTimestamp createdAt,
    29. ModelTimestamp updatedAt,
    30. 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? body,
          String? previousBody,
          String? diffHunk,
          String? path,
          int? position,
          int? originalPosition,
          String? commitId,
          String? originalCommitId,
          String? sha,
          String? state,
          int? reviewId,
          GithubTimelineEvent event,
          @jsonParam GithubUserModel? user,
          @jsonParam GithubUserModel? from,
          @jsonParam GithubUserModel? to,
          @jsonParam GithubProjectModel? project,
          @jsonParam GithubMilestoneValue? milestone,
          @jsonParam GithubReactionValue? reaction,
          @jsonParam GithubIssueModel? issue,
          @jsonParam GithubPullRequestModel? pullRequest,
          @jsonParam GithubLabelValue? label,
          ModelUri? url,
          ModelUri? pullRequestUrl,
          ModelUri? commitUrl,
          ModelUri? links,
          ModelUri? issueUrl,
          ModelTimestamp createdAt,
          ModelTimestamp updatedAt,
          bool fromServer)?
      $default, {
  required TResult orElse(),
}) {
  final _that = this;
  switch (_that) {
    case _GithubPullRequestTimelineModel() when $default != null:
      return $default(
          _that.id,
          _that.body,
          _that.previousBody,
          _that.diffHunk,
          _that.path,
          _that.position,
          _that.originalPosition,
          _that.commitId,
          _that.originalCommitId,
          _that.sha,
          _that.state,
          _that.reviewId,
          _that.event,
          _that.user,
          _that.from,
          _that.to,
          _that.project,
          _that.milestone,
          _that.reaction,
          _that.issue,
          _that.pullRequest,
          _that.label,
          _that.url,
          _that.pullRequestUrl,
          _that.commitUrl,
          _that.links,
          _that.issueUrl,
          _that.createdAt,
          _that.updatedAt,
          _that.fromServer);
    case _:
      return orElse();
  }
}