Utilities and a binding generator for calling C from Dart through FFI
open sourceBSD-3-Clausefree
ffi is the Dart team's package of utilities for working with Dart's Foreign Function Interface: allocating and freeing native memory and converting strings to and from native UTF-8 and UTF-16. Its companion ffigen, from the same repository, generates Dart FFI bindings by parsing C, Objective-C and Swift headers with LibClang, so a Dart or Flutter app can call a native library without writing the bindings by hand. Both are BSD-3-Clause and published on pub.dev.
Problems it solves
- call a C library from my Flutter app
- generate Dart bindings for a native library instead of writing them by hand
- pass strings between Dart and native code
Features
- native memory allocation for Dart FFI
- UTF-8 and UTF-16 string conversion to and from native code
- ffigen: generate Dart bindings from C, Objective-C and Swift headers with LibClang
Limitations
- ffigen parses C headers only, not C++ headers1
Alternatives
The same job
These do what ffi does.
- flutter_rust_bridge Call Rust code from Flutter and Dart, with the glue code generated for you
