nitro_generator 0.2.0 copy "nitro_generator: ^0.2.0" to clipboard
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 @nitroAsync bridging for non-blocking native calls.
  • Streaming: Robust @NitroStream support with configurable backpressure strategies.
  • Binary Records: High-performance @HybridRecord support using a compact binary protocol, eliminating JSON serialization overhead.

Usage #

  1. Define your native module interface in a .native.dart file.
  2. Annotate your classes with @HybridObject, structs with @HybridStruct, etc.
  3. 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

0
likes
120
points
0
downloads

Documentation

Documentation
API reference

Publisher

verified publishershreeman.dev

Weekly Downloads

Code generator for Nitro Modules (Nitrogen). Converts *.native.dart specs to Dart FFI, Kotlin, Swift, and C++ bindings.

Homepage
Repository (GitHub)
View/report issues

Topics

#codegen #ffi #flutter #native #bridge

Funding

Consider supporting this project:

buymeacoffee.com

License

MIT (license)

Dependencies

analyzer, build, dart_style, nitro, path, source_gen

More

Packages that depend on nitro_generator