maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default(
- int? id,
- String? body,
- String? previousBody,
- String? authorAssociation,
- String? commitId,
- String? sha,
- String? state,
- int? reviewId,
- GithubTimelineEvent event,
- GithubUserModel? user,
- GithubUserModel? from,
- GithubUserModel? to,
- GithubProjectModel? project,
- GithubMilestoneValue? milestone,
- GithubReactionValue? reaction,
- GithubIssueModel? issue,
- GithubPullRequestModel? pullRequest,
- GithubLabelValue? label,
- ModelUri? url,
- ModelUri? commitUrl,
- ModelUri? htmlUrl,
- ModelUri? issueUrl,
- ModelUri? links,
- ModelUri? pullRequestUrl,
- ModelTimestamp createdAt,
- ModelTimestamp updatedAt,
- bool fromServer,
- 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();
}
}