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

插件详情v2.2.0

ffi

用于处理外部函数接口(FFI)代码的工具。

AndroidiOSmacOSWindowsLinux
近 30 天下载
1490万
喜欢数
354
Pub 分数
160

安装插件

flutter pub add ffi

插件介绍

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

FFI 包为 Dart 提供了与用 C、Rust 或其他系统级语言编写的原生代码交互的工具。它允许调用函数、访问数据结构以及跨语言边界管理内存,非常适合性能关键的操作或集成现有的原生库。当 Dart 需要与底层系统 API 进行接口交互或优化计算密集型任务时,此包至关重要。它支持包括 Android、iOS、macOS、Windows 和 Linux 在内的多个平台。

适合场景

  • 调用原生C库
  • 将 Rust 代码集成到 Dart 应用程序中
  • 优化性能关键代码
  • 访问系统级 API
  • 与现有原生二进制文件交互

主要特点

  • 平台无关的原生互操作性
  • 对结构体和函数指针的支持
  • 通过原生类型进行内存管理
  • 跨平台兼容性
  • 直接绑定到 C 风格的 API

适合对象

  • 使用原生库的开发者
  • 对性能敏感的应用程序
  • 系统级集成
  • 针对 Flutter 的 Rust 或 C 开发人员
  • 需要直接访问硬件的应用程序

使用建议

  • 需要了解原生代码
  • 如果误用,可能导致崩溃
  • 手动内存管理的风险
  • 与纯 Dart 相比,类型安全性有限
  • 初学者的学习曲线更陡峭

原始 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.

所属分类

源码仓库

使用此插件的项目

所在榜单