when<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 switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<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():
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 _:
throw StateError('Unexpected subclass');
}
}