Search packages, repositories and app categories

Package detailsv2.2.0

ffi

Utilities for working with Foreign Function Interface (FFI) code.

AndroidiOSmacOSWindowsLinux
30-day downloads
14.9M
Likes
354
Pub points
160

Install package

flutter pub add ffi

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The FFI package provides utilities for Dart to interact with native code written in languages like C, Rust, or other systems-level languages. It enables calling functions, accessing data structures, and managing memory across language boundaries, making it ideal for performance-critical operations or integrating existing native libraries. This package is essential when Dart needs to interface with low-level system APIs or optimize computation-heavy tasks. It supports multiple platforms including Android, iOS, macOS, Windows, and Linux.

Use cases

  • Calling native C libraries
  • Integrating Rust code into Dart apps
  • Optimizing performance-critical code
  • Accessing system-level APIs
  • Interfacing with existing native binaries

Key features

  • Platform-agnostic native interoperability
  • Support for structs and function pointers
  • Memory management via native types
  • Cross-platform compatibility
  • Direct binding to C-style APIs

Suitable for

  • Developers using native libraries
  • Performance-sensitive applications
  • System-level integrations
  • Rust or C developers targeting Flutter
  • Apps requiring direct hardware access

Considerations

  • Requires knowledge of native code
  • Potential for crashes if misused
  • Manual memory management risks
  • Limited type safety compared to pure Dart
  • Steeper learning curve for beginners

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Coverage Status

Overview

This repository is home to Dart packages related to FFI and native assets building and bundling.

Documentation

See the doc directory for more documentation.

Packages

Package Description Issues Version
code_assets This package contains the Dart API for code assets in hook/build.dart and hook/link.dart. issues pub package
data_assets This package contains the Dart API for data assets in hook/build.dart and hook/link.dart. issues pub package
ffi Utilities for working with Foreign Function Interface (FFI) code. issues pub package
ffigen Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. issues pub package
hooks This package contains the API for hook/build.dart and hook/link.dart. issues pub package
hooks_runner This package is the backend that invokes hook/build.dart and hook/link.dart from Dart and Flutter. issues pub package
jni A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen. issues pub package
jni_flutter A library to access Flutter Android specific APIs from Dart. issues pub package
jni_util A library to access Flutter Android specific APIs from Dart. issues pub package
jnigen A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. issues pub package
native_toolchain_c A library to invoke the native C compiler installed on the host machine. issues pub package
objective_c A library to access Objective C from Flutter that acts as a support library for package:ffigen. issues pub package
record_use Dart API to access @RecordUse() recorded usages in link hooks. issues pub package
swift2objc A tool for generating bindings that allow interop between Dart and Swift code. issues pub package
swiftgen A tool for generating bindings that allow interop between Dart and Swift code. issues pub package

External packages

Packages not on this repo but also related to FFI and native assets. ❤️

Package Description Version
native_toolchain_cmake A library to invoke CMake for Dart Native Assets. pub package
native_toolchain_go A library to invoke the native Go compiler installed on the host machine. pub package
native_toolchain_ninja A library to invoke Ninja for Dart Native Assets. pub package
native_toolchain_rust A library to build and bundle Rust code for Dart Native Assets. pub package
native_toolchain_zig A library to build and bundle Zig code for Dart Native Assets. pub package

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

For additional information about contributing, see our contributing page.

Categories

Source repository

Projects using this package

Rankings