whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- 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,
- GithubRepositoryModelRef? repository,
- GithubUserModelRef? user,
- GithubUserModelRef? mergedBy,
- List<
GithubUserModelRef?> requestedReviewers, - List<
GithubLabelValue> labels, - GithubPullRequestHeadValue? head,
- GithubPullRequestHeadValue? base,
- GithubMilestoneValue? milestone,
- ModelUri? htmlUrl,
- ModelUri? diffUrl,
- ModelUri? patchUrl,
- ModelTimestamp? closedAt,
- ModelTimestamp? mergedAt,
- 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? 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,
) {
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 null;
}
}