Skip to main content

iroh_flutter 1.2.0 copy "iroh_flutter: ^1.2.0" to clipboard
iroh_flutter: ^1.2.0 copied to clipboard

Flutter plugin for iroh 1.x: peer-to-peer QUIC networking on Android, iOS, macOS, Linux, and Windows. Builds the Rust core into your app.

iroh_flutter #

Flutter plugin for iroh 1.x: peer-to-peer QUIC networking (endpoints, connections, streams, relays, address lookup) on Android, iOS, macOS, Linux, and Windows.

This plugin builds the native Rust core (irohdart_ffi) into your app at build time via cargokit and re-exports the full API of the pure-Dart iroh_quic package. A Rust toolchain is installed automatically by cargokit on first build if you don't already have one.

Usage #

dependencies:
  iroh_flutter: ^1.2.0
import 'package:iroh_flutter/iroh_flutter.dart';

Future<void> main() async {
  await Iroh.init(); // native lib is bundled by the plugin build, no setup step
  final secret = SecretKey.generate();
  print('my id: ${secret.publicKey.toZ32()}');
  // ... Endpoint.bind(), connect(), accept(), etc. See the iroh_quic docs.
}

The API is identical to iroh_quic; see its README and the iroh 1.x docs.

Platforms #

Android iOS macOS Linux Windows
✅ ✅ ✅ ✅ ✅
  • Android: cargokit cross-compiles a per-ABI cdylib via cargo-ndk into jniLibs (NDK r28+ for the 16 KB page-alignment Google Play requirement). minSdk 24. The plugin registers a tiny IrohFlutterPlugin class that hands the application Context to the native library during engine startup. iroh needs it over JNI for system DNS, interface enumeration, and TLS trust. Nothing to configure; but if you build a custom engine setup that skips plugin registration, make sure IrohFlutterPlugin is registered before the first iroh call.
  • iOS / macOS: iOS 13+ / macOS 11+. The plugin supports both Swift Package Manager and CocoaPods.
    • Swift Package Manager (the default from Flutter 3.44): Xcode cannot run cargo in a Swift package build, so the package downloads a prebuilt irohdart_ffi.xcframework from the GitHub release of the plugin version. The app embeds this dynamic framework. No Rust toolchain is necessary.
    • CocoaPods: cargokit builds a staticlib and -force_loads it into the plugin framework. In both cases, the FFI symbols are visible to DynamicLibrary.process().
  • Linux / Windows: cargokit builds a cdylib bundled next to the app.

Pure-Dart / desktop CLI? #

If you don't need Flutter (a dart run CLI or server on desktop), depend on iroh_quic directly and run dart run iroh_quic:setup to download a signed prebuilt library.

Building the native library yourself #

cargokit builds from source by default (it needs the Rust toolchain). To force a source build even when prebuilt binaries are configured, add a cargokit_options.yaml next to your app's pubspec.yaml:

use_precompiled_binaries: false

On iOS and macOS with Swift Package Manager, cargokit does not run. To use a native library that you built yourself, run tool/build_xcframework.sh in a checkout of the repository. The script writes darwin/iroh_flutter/Frameworks/irohdart_ffi.xcframework, and the Swift package then uses it instead of the release download. As an alternative, turn off Swift Package Manager for your app (flutter config --no-enable-swift-package-manager) to use cargokit through CocoaPods.

See the repository README for the full source-build guide.

1
likes
0
points
929
downloads

Publisher

verified publishersnowpine.io

Weekly Downloads

Flutter plugin for iroh 1.x: peer-to-peer QUIC networking on Android, iOS, macOS, Linux, and Windows. Builds the Rust core into your app.

Repository (GitHub)
View/report issues

Topics

#iroh #p2p #networking #quic #ffi

License

unknown (license)

Dependencies

flutter, iroh_quic

More

Packages that depend on iroh_flutter

Packages that implement iroh_flutter