web_bridge library

Everything a generated *.web.bridge.g.dart needs, resolved to the WEB implementations unconditionally.

Generated web bridges import THIS library instead of package:nitro/nitro.dart: the main barrel's conditional exports resolve per-platform (native under the analyzer), while a web bridge must always see the web runtime — NitroRuntime.loadWebModule, NitroWasmModule, WasmArena, the framed-bytes RecordReader/RecordWriter, and friends.

Do NOT import this from code that also runs natively — use package:nitro/nitro.dart there.

Classes

AndroidNativeImpl
Accepted by NitroModule.android.
AnyNativeObject
An opaque reference to any registered native implementation.
AppleNativeImpl
Accepted by NitroModule.ios and NitroModule.macos.
ByteBuffer
A sequence of bytes underlying a typed data object.
ByteData
A fixed-length, random-access sequence of bytes that also provides random and unaligned access to the fixed-width integers and floating point numbers represented by those bytes.
BytesBuilder
Builds a list of bytes, allowing bytes and lists of bytes to be added at the end.
CppImpl
Direct C++ via CMake/FFI. Valid on all native platforms. Implements all native-platform sealed interfaces so it is accepted by every NitroModule platform field except NitroModule.web.
Double
Endian
Endianness of number representation.
Float
Float32List
A fixed-length list of IEEE 754 single-precision binary floating-point numbers that is viewable as a TypedData.
Float32x4
Four 32-bit floating point values.
Float32x4List
A fixed-length list of Float32x4 numbers that is viewable as a TypedData.
Float64List
A fixed-length list of IEEE 754 double-precision binary floating-point numbers that is viewable as a TypedData.
Float64x2
Float64x2 immutable value type and operations.
Float64x2List
A fixed-length list of Float64x2 numbers that is viewable as a TypedData.
HybridEnum
HybridObject
HybridRecord
Marks a Dart class as a rich, binary-serialized record type for use as method parameters, return types, or stream items in a @NitroModule.
HybridStruct
Value type that bridges with C-ABI struct layout.
Int16
Int16List
A fixed-length list of 16-bit signed integers that is viewable as a TypedData.
Int32
Int32List
A fixed-length list of 32-bit signed integers that is viewable as a TypedData.
Int32x4
Four 32-bit integer values.
Int32x4List
A fixed-length list of Int32x4 numbers that is viewable as a TypedData.
Int64
Int64List
A fixed-length list of 64-bit signed integers that is viewable as a TypedData.
Int8
Markers for the fixed-width dart:ffi types, so type-parameter positions in shared code keep compiling on web.
Int8List
A fixed-length list of 8-bit signed integers.
KotlinImpl
Kotlin + JNI bridge. Valid on Android only.
LinuxNativeImpl
Accepted by NitroModule.linux.
MainThread
NativeHandle<T>
Web twin of the native NativeHandle<T>.
NativeImpl
Backward-compatible shorthand namespace. Prefer the per-platform constants (AppleNativeImpl, AndroidNativeImpl, WindowsNativeImpl, LinuxNativeImpl, WebNativeImpl) for clarity.
NativeType
Marker supertype mirroring dart:ffi's NativeType.
NitroAnyBool
NitroAnyDouble
NitroAnyInt
NitroAnyList
NitroAnyMap
NitroAnyNull
NitroAnyObject
NitroAnyString
NitroAnyValue
NitroAsync
NitroBoolWireCodec
Built-in wire codec for bool? — the byte layout of NitroOptBool ([1B hasValue][1B value], packed).
NitroCoalescer
Web twin of NitroCoalescer — demultiplexer for coalesced @nitroNativeAsync completions, backed by a WebReceivePort instead of a ReceivePort.
NitroConfig
Global configuration for the Nitro runtime.
NitroCustomType
Registers a Dart class as a custom FFI bridge type encoded by a NitroFfiCodec.
NitroDoubleWireCodec
Built-in wire codec for double? — the byte layout of NitroOptFloat64 ([1B hasValue][8B float64 LE], packed).
NitroEntryPoint
NitroErr<T extends Object?>
Failure case — carries the native-side error message.
NitroFast
NitroInstanceRegistry
Dart-side registry mapping native instance IDs to live impl objects.
NitroIntWireCodec
Built-in wire codec for int? — the byte layout of NitroOptInt64 ([1B hasValue][8B int64 LE], packed).
NitroModule
Declares a native module: which implementation backs the spec on each platform (omit a platform to skip it) and, optionally, the library name and C symbol prefix the generated bridge uses.
NitroNativeAsync
NitroNullableBool
Collision-free nullable bool for Nitro bridges.
NitroNullableDouble
Collision-free nullable double for Nitro bridges.
NitroNullableInt
Collision-free nullable int for Nitro bridges.
NitroOk<T extends Object?>
Success case — carries the native return value.
NitroOwned
Marks that the native side heap-allocates the returned NativeHandle and Dart takes ownership. The generator will:
NitroPromise<T>
A composable async primitive that mirrors RN Nitro's Promise<T>.
NitroResult
Marks a method's return type as a discriminated success/error result.
NitroResultValue<T extends Object?>
Discriminated success/error result for native methods annotated with @NitroResult().
NitroRuntime
The runtime is called only by generated code. Plugin authors and app developers interact with NitroConfig instead.
NitroSpinStats
Observability for the single-in-flight completion spin (issue #57).
NitroStream
NitroStreamBatch
@NitroStream with batch backpressure configuration. Example: @NitroStream(backpressure: Backpressure.batch, batchMaxSize: 64)
NitroTuple
Marks a Dart 3 positional record typedef as a named tuple type.
NitroVariant
Marks a Dart sealed class as a discriminated union type (sum type / tagged union).
NitroWasmModule
A loaded nitro WASM module: the Emscripten Module object plus typed heap I/O and the module-allocator entry points generated bridges rely on.
NitroWebPorts
Registry mapping integer port ids to message handlers — the web analog of the VM's native-port table.
NitroWireCodec<T extends Object>
Platform-neutral codec for a @NitroCustomType T transported across the bridge as an optional fixed-size value: [1B hasValue][encodedSize-1 bytes].
RecordReader
Streaming binary reader for @HybridRecord types (web edge).
RecordReaderBase
Platform-neutral core of the @HybridRecord binary reader.
RecordWriter
Streaming binary writer for @HybridRecord types (web edge).
RecordWriterBase
Platform-neutral core of the @HybridRecord binary writer.
SwiftImpl
Swift + @_cdecl bridge. Valid on Apple platforms (iOS and macOS) only.
TypedData
A typed view of a sequence of bytes.
TypedDataList<E>
A TypedData fixed-length List-view on the bytes of buffer.
Uint16
Uint16List
A fixed-length list of 16-bit unsigned integers that is viewable as a TypedData.
Uint32
Uint32List
A fixed-length list of 32-bit unsigned integers that is viewable as a TypedData.
Uint64
Uint64List
A fixed-length list of 64-bit unsigned integers that is viewable as a TypedData.
Uint8
Uint8ClampedList
A fixed-length list of 8-bit unsigned integers.
Uint8List
A fixed-length list of 8-bit unsigned integers.
Void
Marker mirroring dart:ffi's Void (e.g. NativeHandle<Void>).
WasmArena
Scoped allocator over a WASM module heap — the web analog of package:ffi's Arena. Every allocation is freed when the scope exits.
WasmImpl
WASM/JS interop bridge. Valid on Web only — dart:ffi is unavailable on web.
WebNativeImpl
Accepted by NitroModule.web.
WebNitroErrorSlot
The C NitroError out-param struct read from WASM linear memory.
WebReceivePort
Web stand-in for dart:isolate's ReceivePort, backed by NitroWebPorts.
WebSendPort
Facade mirroring SendPort for WebReceivePort.
WindowsNativeImpl
Accepted by NitroModule.windows.
ZeroCopy
ZeroCopyBuffer
Buffer of uint8_t — maps to Uint8List. Web: one bulk copy at creation.
ZeroCopyFloat32Buffer
Buffer of float — maps to Float32List.
ZeroCopyFloat64Buffer
Buffer of double — maps to Float64List.
ZeroCopyInt16Buffer
Buffer of int16_t — maps to Int16List.
ZeroCopyInt32Buffer
Buffer of int32_t — maps to Int32List.
ZeroCopyInt64Buffer
Buffer of int64_t — maps to Int64List.
ZeroCopyInt8Buffer
Buffer of int8_t — maps to Int8List.
ZeroCopyUint16Buffer
Buffer of uint16_t — maps to Uint16List.
ZeroCopyUint32Buffer
Buffer of uint32_t — maps to Uint32List.

Enums

Backpressure
NitroLogLevel
Log verbosity levels for NitroConfig.logLevel.
NitroPromiseState
Observable state of a NitroPromise.

Extension Types

EmscriptenModule
The Emscripten Module object of a loaded nitro WASM module.

Extensions

BoolNullableExt on bool?
ByteDataComparison on ByteData
Range comparison operation on ByteData.
DoubleNullableExt on double?
Int16ListComparison on Int16List
Range comparison operation on Int16List.
Int32ListComparison on Int32List
Range comparison operation on Int32List.
Int64ListComparison on Int64List
Range comparison operation on Int64List.
Int8ListComparison on Int8List
Range comparison operation on Int8List.
IntNullableExt on int?
NitroNullableBoolExt on NitroNullableBool
NitroNullableDoubleExt on NitroNullableDouble
NitroNullableIntExt on NitroNullableInt
Uint16ListComparison on Uint16List
Range comparison operation on Uint16List.
Uint32ListComparison on Uint32List
Range comparison operation on Uint32List.
Uint64ListComparison on Uint64List
Range comparison operation on Uint64List.
Uint8ClampedListComparison on Uint8ClampedList
Range comparison operation on Uint8ClampedList.
Uint8ListComparison on Uint8List
Range comparison operation on Uint8List.

Constants

hybridRecord → const HybridRecord
kNitroAnyMapKotlinHelper → const String
Kotlin inline encoder/decoder source, emitted as a string constant for the generator to inject into bridge .kt files.
kNitroAnyMapSwiftHelper → const String
Swift inline encoder/decoder source, emitted by the generator into bridge .swift files.
kNitroWeb → const bool
True when compiling for the web (dart2js or dart2wasm). A compile-time constant, so each compiler tree-shakes the other branch below.
mainThread → const MainThread
Runs the Kotlin/Swift implementation of this method on the platform's main/UI thread instead of the calling thread.
nitroAsync → const NitroAsync
nitroEntryPoint → const NitroEntryPoint
Marks a top-level Future<String> Function(String) (or String Function(String)) in the spec file as a background entry point: native can run it in a fresh isolate even while no Flutter UI is running (a WorkManager job, a push handler, a BGTask), hand it a string argument, and receive the string result. The generator emits the @pragma('vm:entry-point') wrapper that keeps the function alive under AOT, so the function itself needs no pragma.
nitroFast → const NitroFast
Marks a synchronous method as a hot path: the binding is isLeaf: true and the generated body is a bare call — no callSync closure, no logging/slow-call/timeline diagnostics. Measured on Apple Silicon this takes a generated call from ~260 ns to ~13 ns, level with a hand-written dart:ffi binding. The error slot is read in debug builds only (inside an assert), so a native throw surfaces as a HybridException during development and costs nothing in profile/release.
nitroNativeAsync → const NitroNativeAsync
nitroOwned → const NitroOwned
Const shorthand for @NitroOwned.
nitroResult → const NitroResult
Const shorthand for @NitroResult.
nitroVariant → const NitroVariant
Const shorthand for @NitroVariant.
utf8 → const Utf8Codec
An instance of the default implementation of the Utf8Codec.
utf8DecoderAllowMalformed → const Utf8Decoder
zeroCopy → const ZeroCopy

Functions

dartI64(JSAny? v) → int
JS BigInt (or number) → Dart int, for int64_t returns and callback args.
decodeUtf8NoBomStrip(Uint8List bytes) → String
Decodes UTF-8 bytes to a Dart String without stripping leading U+FEFF. dart:convert's Utf8Decoder treats a leading BOM (U+FEFF / 0xEF 0xBB 0xBF) as a stream signature and drops it. Bridge strings are raw data, not streams.
getInt64LE(ByteData data, int offset) → int
Reads a little-endian int64 at offset.
jsI64(int v) → JSAny
Dart int → JS BigInt, for int64_t parameters.
jsonDecode(String source, {Object? reviver(Object? key, Object? value)?}) → dynamic
Parses the string and returns the resulting Json object.
jsonEncode(Object? object, {Object? toEncodable(Object? nonEncodable)?}) → String
Converts object to a JSON string.
nitroWebExportName(String libName) → String
Computes the Emscripten EXPORT_NAME factory for a nitro lib name: benchmark_cpp → createBenchmarkCppModule. The CMake emitter uses the same convention — keep the two in sync.
setInt64LE(ByteData data, int offset, int value) → void
Writes a little-endian int64 at offset. See getInt64LE for the per-compiler contract.
withWasmArena<T>(NitroWasmModule module, T action(WasmArena arena)) → T
Runs action with a scoped WasmArena over module, freeing all arena allocations afterwards — the web analog of withArena/using.

Exceptions / Errors

HybridException
Represents a native exception propagated from Kotlin, Swift, or C++.