NitroCustomType class

Registers a Dart class as a custom FFI bridge type encoded by a NitroFfiCodec.

Equivalent to RN Nitro's JSIConverter<T> specialisation — lets the generator recognise T anywhere in a spec and emit typed encode/decode calls on the Dart side. Native implementations (Kotlin/Swift) receive and return raw ByteArray / UnsafePointer<UInt8>? bytes that the codec produces, so each native language needs its own companion decoder.

codec is the NitroFfiCodec subclass used for Dart-side encoding. encodedSize must equal codec.encodedSize — the generator embeds it in the C bridge to size JNI arrays for parameter passing.

Example:

class ColorCodec extends NitroFfiCodec<Color> {
  const ColorCodec();
  @override int get encodedSize => 5; // 1B flag + 4B RGBA
  @override Pointer<Uint8> encode(Color? v, Arena alloc) { ... }
  @override Color? decode(Pointer<Uint8> ptr) { ... }
}

@NitroCustomType(codec: ColorCodec, encodedSize: 5)
class Color {
  final int r, g, b, a;
  const Color(this.r, this.g, this.b, this.a);
}

Constructors

NitroCustomType({required Type codec, required int encodedSize})
const

Properties

codec → Type
The NitroFfiCodec subclass that handles Dart-side encode/decode.
final
encodedSize → int
Byte count produced by codec.encode — must equal codec.encodedSize.
final
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