whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- 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,
- GithubUserModel? user,
- GithubUserModel? from,
- GithubUserModel? to,
- GithubProjectModel? project,
- GithubMilestoneValue? milestone,
- GithubReactionValue? reaction,
- GithubIssueModel? issue,
- GithubPullRequestModel? pullRequest,
- GithubLabelValue? label,
- ModelUri? url,
- ModelUri? pullRequestUrl,
- ModelUri? commitUrl,
- ModelUri? links,
- ModelUri? issueUrl,
- ModelTimestamp createdAt,
- ModelTimestamp updatedAt,
- bool fromServer,
A variant of when
that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs
TResult? whenOrNull<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,
) {
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 null;
}
}