maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(
- TResult $default(
- int? id,
- String? name,
- String? login,
- String? company,
- String? blog,
- String? location,
- String? email,
- int publicReposCount,
- int publicGistsCount,
- int followersCount,
- int followingCount,
- ModelUri? htmlUrl,
- ModelImageUri? avatarUrl,
- GithubOrganizationType type,
- ModelTimestamp createdAt,
- ModelTimestamp updatedAt,
- 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(
int? id,
String? name,
String? login,
String? company,
String? blog,
String? location,
String? email,
int publicReposCount,
int publicGistsCount,
int followersCount,
int followingCount,
ModelUri? htmlUrl,
ModelImageUri? avatarUrl,
GithubOrganizationType type,
ModelTimestamp createdAt,
ModelTimestamp updatedAt)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _GithubOrganizationModel() when $default != null:
return $default(
_that.id,
_that.name,
_that.login,
_that.company,
_that.blog,
_that.location,
_that.email,
_that.publicReposCount,
_that.publicGistsCount,
_that.followersCount,
_that.followingCount,
_that.htmlUrl,
_that.avatarUrl,
_that.type,
_that.createdAt,
_that.updatedAt);
case _:
return orElse();
}
}