nitro_generator 0.2.0
nitro_generator: ^0.2.0 copied to clipboard
Code generator for Nitro Modules (Nitrogen). Converts *.native.dart specs to Dart FFI, Kotlin, Swift, and C++ bindings.
nitro_generator #
A high-performance code generator for Nitro Modules (Nitrogen). This package converts your Dart interface specifications into optimized native bindings for Android (Kotlin/JNI), iOS (Swift), and C++.
Features #
- Performance-First: Generates lean, zero-copy FFI bindings.
- Cross-Platform: Unified generation for Dart, Kotlin, Swift, and C++.
- Type-Safe: Maps Dart types to their native counterparts with strict validation.
- Complex Types: Supports
@HybridObject,@HybridStruct, and@HybridEnum. - Async Support: seamless
@nitroAsyncbridging for non-blocking native calls. - Streaming: Robust
@NitroStreamsupport with configurable backpressure strategies. - Binary Records: High-performance
@HybridRecordsupport using a compact binary protocol, eliminating JSON serialization overhead.
Usage #
- Define your native module interface in a
.native.dartfile. - Annotate your classes with
@HybridObject, structs with@HybridStruct, etc. - Run the generator:
flutter pub run build_runner build
The generator will produce:
lib/src/generated/*.g.dart: Dart FFI bindings.android/src/main/kotlin/.../*.bridge.g.kt: Kotlin JNI bridge.ios/Classes/*.bridge.g.swift: Swift bridge.ios/Classes/*.bridge.g.mm: Objective-C++ bridge (for exception safety).src/*.bridge.g.h: C++ headers.
Documentation #
For full documentation and getting started guides, visit nitro.shreeman.dev.
License #
MIT