tree: b7f7d3371e1eb38fbc521303aece457d8e23e884
  1. examples/
  2. lib/
  3. rust/
  4. tests/
  5. .gitignore
  6. analysis_options.yaml
  7. flutter_rust_bridge.yaml
  8. pubspec.yaml
  9. README.md
bindings/dart/README.md

Apache OpenDALâ„¢ Dart Binding (WIP)

A Dart binding for Apache OpenDAL: access S3, GCS, Azure Blob, the local filesystem, and 50+ more services through one API. Built on the Rust core via flutter_rust_bridge.

We release the OpenDAL Dart binding independently of the opendal crate (Rust core). For updates and compatibility, use the Dart binding version instead of the opendal crate version.

Useful Links

Installation

This binding is not yet published to pub.dev. To use it, clone the repository and add it as a path dependency, or work directly from bindings/dart/.

You must compile the Rust native library first:

cd rust
cargo build -r
cd ..
dart pub get

The loader first looks for the library in the platform-specific target-triple directory (e.g. rust/target/aarch64-apple-darwin/release/), then falls back to rust/target/release/. For cross-compiled targets, build with --target <triple> so the library is placed in the matching target directory.

Quickstart

import 'dart:typed_data';
import 'package:opendal/opendal.dart';

void main() async {
  final storage = await Storage.init(schemeStr: "memory", map: {"root": "/"});
  final File = storage.initFile();

  final file = File("hello.txt");
  await file.write(Uint8List.fromList("Hello, OpenDAL!".codeUnits));

  final data = await file.read();
  print(String.fromCharCodes(data)); // Hello, OpenDAL!

  await file.delete();
}

The API mirrors dart:io — Storage.initFile() and Storage.initDir() return factory functions that behave like dart:io's File and Directory.

Every method has a blocking *Sync variant alongside the async Future<T> form.

See the user guide for more examples and a full operations reference.

Contributing

Run tests after building the native library:

dart test

Update generated code when upgrading flutter_rust_bridge:

  1. Install the matching flutter_rust_bridge_codegen version.
  2. Update flutter_rust_bridge in both pubspec.yaml and rust/Cargo.toml.
  3. Run flutter_rust_bridge_codegen generate.
  4. Run cargo build -r from rust/.
  5. Run dart test to verify.

The codegen version recorded in generated files, lib/src/rust/frb_generated.dart, and rust/src/frb_generated.rs must all match. Version drift causes startup or test failures.

License and Trademarks

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.