NullableUndefineableJSAnyExtension extension
Helper methods to determine if a value is JavaScript undefined or null.
Note
The members within these extensions may throw depending on the platform. Do not rely on them to be platform-consistent.
JavaScript undefined and JavaScript null are internalized differently
based on the backend. When compiling to JavaScript, Dart null can actually
be JavaScript undefined or JavaScript null. When compiling to Wasm,
that's not the case: there's only one Wasm value null can be. Therefore,
when an interop API returns JavaScript null or JavaScript undefined,
they are both converted to Dart null when compiling to Wasm, and when you
pass a Dart null to an interop API, it is called with JavaScript null.
When compiling to JavaScript, Dart null retains its original JavaScript
value. Avoid writing code where this distinction between null and
undefined matters.
- on
Properties
- isDefinedAndNotNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter - isNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptnull.no setter - isUndefined → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
Whether this value corresponds to JavaScriptundefined.no setter - isUndefinedOrNull → bool
-
Available on JSAny?, provided by the NullableUndefineableJSAnyExtension extension
no setter