Corpus Core Docs

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: colibriFlutterLibraryPath after building desktop binaries (or use a published package that ships them).

Installation

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 null and 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.so is loaded from the plugin’s jniLibs when the engine attaches.
  • iOS – The XCFramework under ios/colibri_flutter/Frameworks/ is linked (CocoaPods + SPM). Dart FFI uses DynamicLibrary.process(). Release device builds require every FFI symbol to be retained via force_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). Pass colibriFlutterLibraryPath after building desktop binaries.
  • Desktop – Build binaries from the repo root with ./scripts/build_flutter_binaries.sh --macos (or --linux, --windows as 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