NitroRuntime class

The runtime is called only by generated code. Plugin authors and app developers interact with NitroConfig instead.

Constructors

NitroRuntime()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

callAsync<T>(Function fn, List<Object?> args, {Object? getError, Object? clearError, String methodName = ''}) Future<T>
@nitroAsync on web: there are no isolates, so fn runs on the main thread after a single event-loop hop. Long-running native work will jank the UI — prefer @nitroNativeAsync for genuinely asynchronous impls.
callSync<T>(T call(), {String methodName = ''}) → T
Calls a bridge function synchronously, with the same logging and slow-call detection as the native runtime.
checkAbiVersion(String libName, int readVersion()) → void
checkError(dynamic get(), void clear()) → void
Checks the legacy two-call error protocol. On web the generated bridge passes Dart closures over the module exports.
checkLinkChecksum(String libName, String expectedChecksum, String readChecksum()) → void
checkSupportedPlatform(String libName, {required bool ios, required bool android, required bool macos, required bool windows, required bool linux, required bool web}) → void
deferredClose(Object? old) → void
API-parity shim for the native deferredClose(NativeCallable?) — the web bridge uses deferredCloseWebFunction instead.
deferredCloseWebFunction(NitroWasmModule module, int? oldFnPtr) → void
Web analog of the native deferred NativeCallable.close: releases a replaced callback's function-table slot on the next microtask, after the bridge call that switched native over to the new slot has returned.
dispose() Future<void>
Tears down the runtime: clears the module cache. After calling this, modules must be loaded again before use.
init({int? isolatePoolSize}) Future<void>
Initialises the runtime. On web there is no isolate pool to warm — this exists for API parity so main() code runs unchanged.
loadLib(String libName) → Never
Native-only entry point. On web, module loading is asynchronous — see loadWebModule / the generated ensure<Class>Ready().
loadLibForTargets(String libName, {required bool ios, required bool android, required bool macos, required bool windows, required bool linux, required bool web}) → Never
loadWebModule(String libName, {String? jsUrl, String? assetPackage}) Future<NitroWasmModule>
Loads the Emscripten glue script for libName and instantiates its module. Idempotent: concurrent and repeated calls share one load.
logLifecycle(String tag, String message) → void
Logs a lifecycle event (init, dispose) for a module.
openNativeAsync<T>({required void call(int dartPort), required T unpack(dynamic raw), void cleanup()?, String methodName = ''}) Future<T>
Opens a single-use WebReceivePort, hands its port id to call so the WASM implementation can post the result through the module post callback, then waits for exactly one message and converts it with unpack. Mirrors the native contract, including NitroConfig.nativeAsyncTimeoutMs.
openStream<T>({required void register(int dartPort), required T unpack(dynamic message), required void release(int dartPort), required Backpressure backpressure, String? debugLabel, WebReceivePort? testPort}) Stream<T>
Opens a stream from a WASM event source over a WebReceivePort, mirroring the native lifecycle (explicit cancel, GC finalizer safety net; hot restart tears down the JS context wholesale).
releaseLib(String libName) → void
Decrements the reference count for libName; drops the cached module at zero. The browser has no dlclose — dropping references lets the JS GC collect the instance once generated bridges release theirs.
retainLib(String libName) → void
Takes a reference to an already-loaded libName, balancing the releaseLib a generated bridge performs in dispose().
throwIfOutParamError(WebNitroErrorSlot slot) → void
Checks an S8-style out-parameter error slot after a sync bridge call — the web counterpart of the native throwIfOutParamError(Pointer<...>). Reads the slot from module memory; if an error is present, frees the strdup'd fields with the module's nitro_free, resets the slot, and throws a HybridException.
throwIfOutParamErrorAndFree(WebNitroErrorSlot slot) → void
Checks and frees a per-call error slot (@nitroNativeAsync) — the web counterpart of the native throwIfOutParamErrorAndFree.
webModule(String libName) NitroWasmModule
Returns the loaded module for libName, or throws with the fix.

Constants

expectedAbiVersion → const int
useNativeBindings → const bool
Web never uses @Native<F> direct dispatch.