maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default(
- String? sha,
- String? message,
- int commentCount,
- int additionsCount,
- int deletionsCount,
- int totalCount,
- ModelUri? url,
- ModelUri? htmlUrl,
- ModelUri? commentsUrl,
- GithubUserModelRef? author,
- GithubUserModelRef? committer,
- ModelTimestamp? authorDate,
- ModelTimestamp? committerDate,
- List<
GithubCommitModel> parents, - List<
GithubContentModel> contents, - 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(
String? sha,
String? message,
int commentCount,
int additionsCount,
int deletionsCount,
int totalCount,
ModelUri? url,
ModelUri? htmlUrl,
ModelUri? commentsUrl,
@refParam GithubUserModelRef? author,
@refParam GithubUserModelRef? committer,
ModelTimestamp? authorDate,
ModelTimestamp? committerDate,
@jsonParam List<GithubCommitModel> parents,
@jsonParam List<GithubContentModel> contents,
bool fromServer)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _GithubCommitModel() when $default != null:
return $default(
_that.sha,
_that.message,
_that.commentCount,
_that.additionsCount,
_that.deletionsCount,
_that.totalCount,
_that.url,
_that.htmlUrl,
_that.commentsUrl,
_that.author,
_that.committer,
_that.authorDate,
_that.committerDate,
_that.parents,
_that.contents,
_that.fromServer);
case _:
return orElse();
}
}