whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
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(
bool? fetch,
bool? console,
bool? buffer,
bool? stringDecoder,
bool? timers,
bool? stream,
bool? crypto,
bool? abort,
bool? url,
bool? events,
bool? json)?
$default,
) {
final _that = this;
switch (_that) {
case _JsBuiltinOptions() when $default != null:
return $default(
_that.fetch,
_that.console,
_that.buffer,
_that.stringDecoder,
_that.timers,
_that.stream,
_that.crypto,
_that.abort,
_that.url,
_that.events,
_that.json);
case _:
return null;
}
}