搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單