搜索插件、代码仓与 APP 分类

插件详情v23.0.0

ffigen

使用 LibClang 解析 C、Objective-C 和 Swift 文件的 FFI 绑定生成器。

AndroidiOSmacOSWindowsLinux
近 30 天下载
109万
喜欢数
338
Pub 分数
160

安装插件

flutter pub add ffigen

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

ffigen 是一个代码生成器,可为 C、Objective-C 和 Swift 库生成 Dart FFI(外部函数接口)绑定。它使用 LibClang 解析原生头文件,并自动生成相应的 Dart 代码,从而实现 Dart 与原生代码之间的无缝互操作。这简化了从 Dart 调用原生函数的过程,无需手动创建绑定。适用于对性能要求较高的应用,或在 Flutter 应用中集成现有的原生库。

适合场景

  • 将C库集成到Flutter应用中
  • 从 Dart 调用原生函数
  • 为 iOS 和 Android 生成 FFI 绑定
  • 在 Flutter 中使用 Swift 库
  • 构建高性能原生扩展

主要特点

  • 自动生成 FFI 绑定
  • 支持 C、Objective-C 和 Swift
  • 使用 LibClang 进行精确解析
  • 生成干净、可读的 Dart 代码
  • 可配置的输出和命名

适合对象

  • 使用原生 C/C++ 库的开发人员
  • 需要高性能原生调用的Flutter应用
  • 维护跨平台原生集成的团队
  • 需要最少 FFI 杂项的项目

使用建议

  • 需要安装 LibClang
  • 可能需要平台特定的配置
  • 生成的代码可能需要手动调整
  • 不适用于动态或运行时加载的库
  • 某些平台上的构建设置复杂度

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

依赖

依赖清单 18 项

源码仓库

使用此插件的项目

所在榜单