nitro library

Classes

Abi
An application binary interface (ABI).
AbiSpecificInteger
The supertype of all Abi-specific integer types.
AbiSpecificIntegerMapping
Mapping for a subtype of AbiSpecificInteger.
Allocator
Manages memory on the native heap.
AndroidNativeImpl
Accepted by NitroModule.android.
AnyNativeObject
An opaque reference to any registered native implementation.
AppleNativeImpl
Accepted by NitroModule.ios and NitroModule.macos.
Arena
An Allocator which frees all allocations at the same time.
Array<T extends NativeType>
A fixed-sized array of Ts.
Bool
Represents a native bool in C.
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.
CallocAllocator
Manages memory on the native heap.
Char
The C char type.
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.
Dart_CObject
Opaque, not exposing it's members.
DartRepresentationOf
DefaultAsset
Annotation specifying the default asset ID for the current library.
Double
Represents a native 64 bit double in C.
DynamicLibrary
A dynamically loaded native library.
Endian
Endianness of number representation.
Finalizable
Marker interface for objects which should not be finalized too soon.
Float
Represents a native 32 bit float in C.
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.
Handle
Represents Dart_Handle from dart_api.h in C.
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.
Int
The C int type.
Int16
Represents a native signed 16 bit integer in C.
Int16List
A fixed-length list of 16-bit signed integers that is viewable as a TypedData.
Int32
Represents a native signed 32 bit integer in C.
Int32List
A fixed-length list of 32-bit signed integers that is viewable as a TypedData.
Int32x4
Int32x4 and operations.
Int32x4List
A fixed-length list of Int32x4 numbers that is viewable as a TypedData.
Int64
Represents a native signed 64 bit integer in C.
Int64List
A fixed-length list of 64-bit signed integers that is viewable as a TypedData.
Int8
Represents a native signed 8 bit integer in C.
Int8List
A fixed-length list of 8-bit signed integers.
IntPtr
The C intptr_t type.
IsolatePool
A fixed pool of long-lived worker isolates with a persistent reply port.
KotlinImpl
Kotlin + JNI bridge. Valid on Android only.
LazyRecordList<T>
A read-only List backed directly by a native binary buffer produced by RecordWriter.encodeIndexedList.
LinuxNativeImpl
Accepted by NitroModule.linux.
Long
The C long int, aka. long, type.
LongLong
The C long long type.
MainThread
MallocAllocator
Manages memory on the native heap.
Native<T>
Annotation binding an external declaration to its native implementation.
NativeApi
Utilities for accessing the Dart VM API from Dart code or from C code via dart_api_dl.h.
NativeCallable<T extends Function>
A native callable which listens for calls to a native function.
NativeFinalizer
A native finalizer which can be attached to Dart objects.
NativeFunction<T extends Function>
Represents a function type in C.
NativeHandle<T extends NativeType>
A lightweight wrapper around a raw native pointer that crosses the Nitro bridge without any codec overhead.
NativeImpl
Backward-compatible shorthand namespace. Prefer the per-platform constants (AppleNativeImpl, AndroidNativeImpl, WindowsNativeImpl, LinuxNativeImpl, WebNativeImpl) for clarity.
NativeType
NativeType's subtypes represent a native type in C.
NitroAnyBool
NitroAnyDouble
NitroAnyInt
NitroAnyList
NitroAnyMap
NitroAnyNull
NitroAnyObject
NitroAnyString
NitroAnyValue
NitroAsync
NitroBoolCodec
Built-in codec for bool? — backed by NitroOptBool.
NitroBoolWireCodec
Built-in wire codec for bool? — the byte layout of NitroOptBool ([1B hasValue][1B value], packed).
NitroCoalescer
Demultiplexer for coalesced @nitroNativeAsync completions.
NitroConfig
Global configuration for the Nitro runtime.
NitroCustomType
Registers a Dart class as a custom FFI bridge type encoded by a NitroFfiCodec.
NitroDoubleCodec
Built-in codec for double? — backed by NitroOptFloat64.
NitroDoubleWireCodec
Built-in wire codec for double? — the byte layout of NitroOptFloat64 ([1B hasValue][8B float64 LE], packed).
NitroErr<T extends Object?>
Failure case — carries the native-side error message.
NitroErrorFfi
A C-compatible struct for passing exception data over the FFI boundary.
NitroFfiCodec<T extends Object>
Codec for a type T that can be transported across the C FFI bridge as an optional value. This is the Dart/FFI equivalent of RN Nitro's JSIConverter<std::optional<T>>.
NitroInstanceRegistry
Dart-side registry mapping native instance IDs to live impl objects.
NitroIntCodec
Built-in codec for int? — backed by NitroOptInt64.
NitroIntWireCodec
Built-in wire codec for int? — the byte layout of NitroOptInt64 ([1B hasValue][8B int64 LE], packed).
NitroModule
NitroNativeAllocator
An Allocator backed by a module's exported <lib>_nitro_alloc / <lib>_nitro_free symbols (plain C-runtime malloc/free).
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.
NitroOptBool
NitroOptFloat64
NitroOptInt64
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.
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).
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].
Opaque
Opaque's subtypes represent opaque types in C.
Packed
Annotation to specify on Struct subtypes to indicate that its members need to be packed.
Pointer<T extends NativeType>
Represents a pointer into the native C memory. Cannot be extended.
ReceivePort
Together with SendPort, the only means of communication between isolates.
RecordReader
Streaming binary reader for @HybridRecord types (native dart:ffi edge).
RecordReaderBase
Platform-neutral core of the @HybridRecord binary reader.
RecordWriter
Streaming binary writer for @HybridRecord types (native dart:ffi edge).
RecordWriterBase
Platform-neutral core of the @HybridRecord binary writer.
SendPort
Sends messages to its ReceivePorts.
Short
The C short type.
SignedChar
The C signed char type.
Size
The C size_t type.
SizedNativeType
A NativeType with a known size.
Struct
The supertype of all FFI struct types.
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
Represents a native unsigned 16 bit integer in C.
Uint16List
A fixed-length list of 16-bit unsigned integers that is viewable as a TypedData.
Uint32
Represents a native unsigned 32 bit integer in C.
Uint32List
A fixed-length list of 32-bit unsigned integers that is viewable as a TypedData.
Uint64
Represents a native unsigned 64 bit integer in C.
Uint64List
A fixed-length list of 64-bit unsigned integers that is viewable as a TypedData.
Uint8
Represents a native unsigned 8 bit integer in C.
Uint8ClampedList
A fixed-length list of 8-bit unsigned integers.
Uint8List
A fixed-length list of 8-bit unsigned integers.
UintPtr
The C uintptr_t type.
Union
The supertype of all FFI union types.
UnsignedChar
The C unsigned char type.
UnsignedInt
The C unsigned int type.
UnsignedLong
The C unsigned long int, aka. unsigned long, type.
UnsignedLongLong
The C unsigned long long type.
UnsignedShort
The C unsigned short type.
Utf16
The contents of a native zero-terminated array of UTF-16 code units.
Utf8
The contents of a native zero-terminated array of UTF-8 code units.
VarArgs<T extends Record>
The types of variadic arguments passed in C.
Void
Represents a void type in C.
WasmImpl
WASM/JS interop bridge. Valid on Web only — dart:ffi is unavailable on web.
WChar
The C wchar_t type.
WebNativeImpl
Accepted by NitroModule.web.
WindowsNativeImpl
Accepted by NitroModule.windows.
ZeroCopy
ZeroCopyBuffer
Zero-copy buffer backed by uint8_t* — maps to Uint8List.
ZeroCopyFloat32Buffer
Zero-copy buffer backed by float* — maps to Float32List.
ZeroCopyFloat64Buffer
Zero-copy buffer backed by double* — maps to Float64List.
ZeroCopyInt16Buffer
Zero-copy buffer backed by int16_t* — maps to Int16List.
ZeroCopyInt32Buffer
Zero-copy buffer backed by int32_t* — maps to Int32List.
ZeroCopyInt64Buffer
Zero-copy buffer backed by int64_t* — maps to Int64List.
ZeroCopyInt8Buffer
Zero-copy buffer backed by int8_t* — maps to Int8List.
ZeroCopyUint16Buffer
Zero-copy buffer backed by uint16_t* — maps to Uint16List.
ZeroCopyUint32Buffer
Zero-copy buffer backed by uint32_t* — maps to Uint32List.

Enums

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

Extensions

AbiSpecificIntegerArray on Array<T>
Bounds checking indexing methods on Arrays of AbiSpecificInteger.
AbiSpecificIntegerPointer on Pointer<T>
Extension on Pointer specialized for the type argument AbiSpecificInteger.
AllocatorAlloc on Allocator
Extension on Allocator to provide allocation with NativeType.
ArrayAddress on Array<T>
ArrayArray on Array<Array<T>>
Bounds checking indexing methods on Arrays of Array.
BoolAddress on bool
BoolArray on Array<Bool>
Bounds checking indexing methods on Arrays of Bool.
BoolNullableExt on bool?
BoolPointer on Pointer<Bool>
Extension on Pointer specialized for the type argument Bool.
DoubleAddress on double
DoubleArray on Array<Double>
Bounds checking indexing methods on Arrays of Double.
DoubleNullableExt on double?
DoublePointer on Pointer<Double>
Extension on Pointer specialized for the type argument Double.
DynamicLibraryExtension on DynamicLibrary
Method which must not be invoked dynamically.
Float32ListAddress on Float32List
Float64ListAddress on Float64List
FloatArray on Array<Float>
Bounds checking indexing methods on Arrays of Float.
FloatPointer on Pointer<Float>
Extension on Pointer specialized for the type argument Float.
Int16Array on Array<Int16>
Bounds checking indexing methods on Arrays of Int16.
Int16ListAddress on Int16List
Int16Pointer on Pointer<Int16>
Extension on Pointer specialized for the type argument Int16.
Int32Array on Array<Int32>
Bounds checking indexing methods on Arrays of Int32.
Int32ListAddress on Int32List
Int32Pointer on Pointer<Int32>
Extension on Pointer specialized for the type argument Int32.
Int64Array on Array<Int64>
Bounds checking indexing methods on Arrays of Int64.
Int64ListAddress on Int64List
Int64Pointer on Pointer<Int64>
Extension on Pointer specialized for the type argument Int64.
Int8Array on Array<Int8>
Bounds checking indexing methods on Arrays of Int8.
Int8ListAddress on Int8List
Int8Pointer on Pointer<Int8>
Extension on Pointer specialized for the type argument Int8.
IntAddress on int
IntNullableExt on int?
NativeFunctionPointer on Pointer<NativeFunction<NF>>
Extension on Pointer specialized for the type argument NativeFunction.
NativePort on SendPort
Extension to retrieve the native Dart_Port from a SendPort.
NitroAnyMapNative on NitroAnyMap
NitroFloat32ListExtension on Float32List
NitroFloat64ListExtension on Float64List
NitroInt16ListExtension on Int16List
NitroInt32ListExtension on Int32List
NitroInt64ListExtension on Int64List
NitroInt8ListExtension on Int8List
NitroNullableBoolExt on NitroNullableBool
NitroNullableBoolNative on NitroNullableBool
NitroNullableDoubleExt on NitroNullableDouble
NitroNullableDoubleNative on NitroNullableDouble
NitroNullableIntExt on NitroNullableInt
NitroNullableIntNative on NitroNullableInt
NitroOptArena on Arena
NitroOptBoolDecode on NitroOptBool
NitroOptBoolPointer on Pointer<NitroOptBool>
NitroOptFloat64Decode on NitroOptFloat64
NitroOptFloat64Pointer on Pointer<NitroOptFloat64>
NitroOptInt64Decode on NitroOptInt64
NitroOptInt64Pointer on Pointer<NitroOptInt64>
NitroPointerExtension on Pointer<Utf8>
NitroStringExtension on String
NitroUint16ListExtension on Uint16List
NitroUint32ListExtension on Uint32List
NitroUint64ListExtension on Uint64List
NitroUint8ListExtension on Uint8List
PointerArray on Array<Pointer<T>>
Bounds checking indexing methods on Arrays of Pointer.
PointerPointer on Pointer<Pointer<T>>
Extension on Pointer specialized for the type argument Pointer.
StringUtf16Pointer on String
Extension method for converting a String to a Pointer<Utf16>.
StringUtf8Pointer on String
Extension method for converting a String to a Pointer<Utf8>.
StructAddress on T
StructArray on Array<T>
Bounds checking indexing methods on Arrays of Struct.
StructPointer on Pointer<T>
Extension on Pointer specialized for the type argument Struct.
Uint16Array on Array<Uint16>
Bounds checking indexing methods on Arrays of Uint16.
Uint16ListAddress on Uint16List
Uint16Pointer on Pointer<Uint16>
Extension on Pointer specialized for the type argument Uint16.
Uint32Array on Array<Uint32>
Bounds checking indexing methods on Arrays of Uint32.
Uint32ListAddress on Uint32List
Uint32Pointer on Pointer<Uint32>
Extension on Pointer specialized for the type argument Uint32.
Uint64Array on Array<Uint64>
Bounds checking indexing methods on Arrays of Uint64.
Uint64ListAddress on Uint64List
Uint64Pointer on Pointer<Uint64>
Extension on Pointer specialized for the type argument Uint64.
Uint8Array on Array<Uint8>
Bounds checking indexing methods on Arrays of Uint8.
Uint8ListAddress on Uint8List
Uint8Pointer on Pointer<Uint8>
Extension on Pointer specialized for the type argument Uint8.
UnionAddress on T
UnionArray on Array<T>
Bounds checking indexing methods on Arrays of Union.
UnionPointer on Pointer<T>
Extension on Pointer specialized for the type argument Union.
Utf16Pointer on Pointer<Utf16>
Extension method for converting aPointer<Utf16> to a String.
Utf8Pointer on Pointer<Utf8>
Extension method for converting a Pointer<Utf8> to a String.

Constants

calloc → const CallocAllocator
Manages memory on the native heap.
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.
malloc → const MallocAllocator
Manages memory on the native heap.
nitroAsync → const NitroAsync
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

Properties

nullptr Pointer<Never>
Represents a pointer into the native C memory corresponding to 'NULL', e.g. a pointer with address 0.
final
zoneArena Arena
A zone-specific Arena.
no setter

Functions

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.
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.
nitroAnyMapFromNative(Pointer<Uint8> ptr) NitroAnyMap
Decode a NitroAnyMap from a native pointer produced by NitroAnyMapNative.toNative or the C bridge.
nitroNullableBoolFromNative(Pointer<Uint8> ptr) NitroNullableBool
Decodes a NitroNullableBool from a framed native buffer.
nitroNullableDoubleFromNative(Pointer<Uint8> ptr) NitroNullableDouble
Decodes a NitroNullableDouble from a framed native buffer.
nitroNullableIntFromNative(Pointer<Uint8> ptr) NitroNullableInt
Decodes a NitroNullableInt from the framed buffer produced by toNative / a native bridge.
setInt64LE(ByteData data, int offset, int value) → void
Writes a little-endian int64 at offset. See getInt64LE for the per-compiler contract.
sizeOf<T extends SizedNativeType>() int
Number of bytes used by native type T.
using<R>(R computation(Arena arena), [Allocator wrappedAllocator = calloc]) → R
Runs computation with a new Arena, and releases all allocations at the end.
withArena<T>(T action(Arena arena)) → T
withZoneArena<R>(R computation(), [Allocator wrappedAllocator = calloc]) → R
Creates a zoned Arena to manage native resources.

Typedefs

Dart_NativeMessageHandler = Void Function(Int64, Pointer<Dart_CObject>)
NativeFinalizerFunction = NativeFunction<Void Function(Pointer<Void> token)>
The native function type for NativeFinalizers.
NativeRelease<T extends NativeType> = void Function(Pointer<T> pointer)
A function that releases native memory.

Exceptions / Errors

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