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