Flutter
Flutter plugin for Colibri Stateless with bundled native binaries for Android, iOS, macOS, Linux (and Windows when built on Windows). No manual build or libraryPath required on mobile; on desktop you pass the plugin’s bundled library path.
Overview
colibri_flutter is the same Colibri Dart API as colibri_stateless, packaged as a Flutter plugin with pre-built native libraries. Use it in Flutter apps when you want verified RPC without managing the native build yourself. Flutter web is not supported (no FFI).
When to use
- Mobile (Android / iOS) – Use colibri_flutter from pub.dev; binaries are included.
- Desktop (macOS / Linux / Windows) – Use colibri_flutter and pass
libraryPath: colibriFlutterLibraryPathafter building desktop binaries (or use a published package that ships them).
Installation
pub.dev (recommended for mobile)
dependencies:
colibri_flutter: ^0.2.1
flutter pub get
Path dependency (development)
dependencies:
colibri_flutter:
path: /path/to/colibri-stateless/bindings/dart/flutter/colibri_flutter
colibri_stateless:
path: /path/to/colibri-stateless/bindings/dart
Usage
import 'package:colibri_flutter/colibri_flutter.dart';
// Android/iOS: libraryPath not needed (plugin loads the lib).
// macOS/Linux: use bundled lib path.
final colibri = Colibri(chainId: 1, libraryPath: colibriFlutterLibraryPath);
final blockNumber = await colibri.rpc('eth_blockNumber', []);
colibri.close();
- On Android and iOS, the plugin loads the native library automatically; colibriFlutterLibraryPath is
nulland can be omitted. - On macOS and Linux, pass libraryPath: colibriFlutterLibraryPath so the app uses the plugin’s bundled library (you must have built desktop binaries for it to be present).
Platform notes
- Android –
libcolibri.sois loaded from the plugin’sjniLibswhen the engine attaches. - iOS – The XCFramework under
ios/colibri_flutter/Frameworks/is linked (CocoaPods + SPM). Dart FFI usesDynamicLibrary.process(). Release device builds require every FFI symbol to be retained viaforce_link.c/-force_load(use plugin ≥ 0.2.1). When building yourself, run the iOS binary build script or use the published package. - macOS – Podspec depends on
FlutterMacOS(required since 0.2.1 for Explicit Modules). PasscolibriFlutterLibraryPathafter building desktop binaries. - Desktop – Build binaries from the repo root with
./scripts/build_flutter_binaries.sh --macos(or--linux,--windowsas appropriate). Requires Android NDK for Android, Xcode on macOS for iOS. - Storage – On Android and iOS, if you omit storage, the client uses in-memory storage by default (native file storage is not used on mobile).
Building native binaries (maintainers)
From the repository root:
./scripts/build_flutter_binaries.sh
# or per platform:
./scripts/build_flutter_binaries.sh --android
./scripts/build_flutter_binaries.sh --ios
./scripts/build_flutter_binaries.sh --macos
./scripts/build_flutter_binaries.sh --linux
./scripts/build_flutter_binaries.sh --windows
Output: Android jniLibs, iOS XCFramework, and desktop libraries as documented in the main Dart README.
Further information
- Plugin README: flutter/colibri_flutter/README.md
- Specification: GitBook – Bindings
- Pub package: colibri_flutter