nitroFast top-level constant
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.
The contract the native side must keep: never throw (in release nothing
reads the error slot, so the error is lost), never call back into Dart,
never block. Arena arguments
(String, records, typed data) keep the arena path; scalars, enums,
nullable scalars and NativeHandle parameters are the intended shapes.
Not allowed on Future/Stream/@nitroAsync methods.
Composes with @nitroNativeAsync: the Dart signature stays Future<T> but
the call completes inline — no port, no post, no isolate wake. The native
implementation is then a plain synchronous function (Kotlin fun, Swift
func, C++ method) that must not block; the future is completed from its
return value. Use it for APIs that must be Future-shaped (a platform
interface, an interface other implementations satisfy asynchronously) whose
native side has the answer immediately.
@nitroFast
int writeByte(NativeHandle<Void> writer, int byte);
The older ...Fast name suffix keeps working and means the same thing.
Implementation
const nitroFast = NitroFast();