whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- bool? abort,
- bool? assert_,
- bool? asyncHooks,
- bool? buffer,
- bool? childProcess,
- bool? console,
- bool? crypto,
- bool? dns,
- bool? events,
- bool? exceptions,
- bool? fetch,
- bool? fs,
- bool? net,
- bool? os,
- bool? path,
- bool? perfHooks,
- bool? process,
- bool? streamWeb,
- bool? stringDecoder,
- bool? timers,
- bool? tty,
- bool? url,
- bool? util,
- bool? zlib,
- bool? json,
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? abort,
bool? assert_,
bool? asyncHooks,
bool? buffer,
bool? childProcess,
bool? console,
bool? crypto,
bool? dns,
bool? events,
bool? exceptions,
bool? fetch,
bool? fs,
bool? navigator,
bool? net,
bool? os,
bool? path,
bool? perfHooks,
bool? process,
bool? streamWeb,
bool? stringDecoder,
bool? timers,
bool? tty,
bool? url,
bool? util,
bool? zlib,
bool? json)?
$default,
) {
final _that = this;
switch (_that) {
case _JsBuiltinOptions() when $default != null:
return $default(
_that.abort,
_that.assert_,
_that.asyncHooks,
_that.buffer,
_that.childProcess,
_that.console,
_that.crypto,
_that.dns,
_that.events,
_that.exceptions,
_that.fetch,
_that.fs,
_that.navigator,
_that.net,
_that.os,
_that.path,
_that.perfHooks,
_that.process,
_that.streamWeb,
_that.stringDecoder,
_that.timers,
_that.tty,
_that.url,
_that.util,
_that.zlib,
_that.json);
case _:
return null;
}
}