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