whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- String id,
- String status,
- String owner,
- String repo,
- String? teamId,
- String? workflowId,
- String? workflowFileName,
- String? installationToken,
- String? commitSha,
- int? pullRequestNumber,
- int? runCount,
- String? latestRunId,
- String? tagName,
- String? branch,
- String? jobKey,
- String? workflowRunId,
- List<
String> ? needs, - String? githubBaseUrl,
- String? githubApiBaseUrl,
- @DateTimeConverter() DateTime? createdAt,
- @DateTimeConverter() DateTime? updatedAt,
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( String id, String status, String owner, String repo, String? teamId, String? workflowId, String? workflowFileName, String? installationToken, String? commitSha, int? pullRequestNumber, int? runCount, String? latestRunId, String? tagName, String? branch, String? jobKey, String? workflowRunId, List<String>? needs, String? githubBaseUrl, String? githubApiBaseUrl, @DateTimeConverter() DateTime? createdAt, @DateTimeConverter() DateTime? updatedAt)? $default,) {final _that = this;
switch (_that) {
case _BuildJob() when $default != null:
return $default(_that.id,_that.status,_that.owner,_that.repo,_that.teamId,_that.workflowId,_that.workflowFileName,_that.installationToken,_that.commitSha,_that.pullRequestNumber,_that.runCount,_that.latestRunId,_that.tagName,_that.branch,_that.jobKey,_that.workflowRunId,_that.needs,_that.githubBaseUrl,_that.githubApiBaseUrl,_that.createdAt,_that.updatedAt);case _:
return null;
}
}