maybeWhen<TResult extends Object?> method
TResult
maybeWhen<TResult extends Object?>(})
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? plusOne,
int? minusOne,
int? confused,
int? eyes,
int? heart,
int? hooray,
int? laugh,
int? rocket,
int totalCount,
ModelUri? url)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _GithubReactionValue() when $default != null:
return $default(
_that.plusOne,
_that.minusOne,
_that.confused,
_that.eyes,
_that.heart,
_that.hooray,
_that.laugh,
_that.rocket,
_that.totalCount,
_that.url);
case _:
return orElse();
}
}