dart-use-ffigen

A guide for using the Dart package ffigen to generate connections between Dart code and native C, Objective-C, or Swift code.

In plain words
What is it for?
Use it when adding or extending Dart integrations with native libraries, including locating headers, creating the generator script, selecting definitions, and checking the generated result.
Why use it?
Generating these connections from native header files avoids the errors and maintenance burden of writing low-level bindings by hand.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/flutter/agent-plugins/dart-use-ffigen
Any agent
npx skills add flutter/agent-plugins --skill dart-use-ffigen
Clone the repo
git clone --depth 1 https://github.com/flutter/agent-plugins

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,684 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.02684
Opus 5 $0.00030 $0.01342
Sonnet 5 $0.00012 $0.00537
Haiku 4.5 $0.00006 $0.00268

Measured 2d ago against content hash 129ae526e854, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dart-use-ffigen scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills/dart-use-ffigen/SKILL.md · 219 lines

How it starts

The opening of the file, as written. The whole thing — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Generating FFI Bindings using package:ffigen

Contents

Introduction

Automate and standardize the generation of FFI bindings using package:ffigen (FfiGenerator). Writing FFI bindings by hand is error-prone, brittle, and highly discouraged.

Constraints

  • No Hand-Written FFI Bindings: If native headers (.h files) exist or are generated by a build step, never write manual DynamicLibrary.lookup, @Native external functions, or raw struct classes. Always use FfiGenerator to generate them.
  • Generator Location: The generator script should be located at tool/ffigen.dart within the target package root.
  • Header Location: If the native header files are third-party, they should be located in third_party/ within the target package (otherwise placing them in a src/ directory at the package root is also acceptable). If the headers are not in one of these standard locations, notify the user that it would be cleaner to move the header files to the standard location (e.g., third_party/).
  • Targeted Inclusion Filters: Avoid importing an entire native library unless specifically needed. Always apply precise inclusion lists using positive matches to minimize the size and cognitive load of the generated code (e.g., using Functions.includeSet or filtering matches in include closures).
  • Output Setup: If the generated FFI bindings interface with a third-party library (or reference third-party headers), the generated files must always be placed under lib/src/third_party/. The primary generated FFI bindings file must strictly use the .g.dart extension (e.g. sqlite3.g.dart).
  • Preamble & License Headers: Always supply a premium preamble in the Output class to specify the license. This must match the native third-party library's license, explicitly include the copyright header of the target native header file, and contain an automatic generation warning (e.g. // Generated by package:ffigen. Do not edit manually.).
  • No Unnecessary Commits of Stale Bindings: Ensure you run the generator script and check if the generated files have changed before finishing your task. Always verify the package by running dart analyze.
  • Record Usage and Tree Shaking: If the package is integrated into standard runtime execution or compiles native assets via native hooks:
    • Enable recorded usage on all functions by setting recordUse: (_) => true under Functions.
    • Specify the recordUseMapping target in Output (which must strictly be a .g.dart file under lib/src/third_party/, e.g. lib/src/third_party/sqlite3.record_use_mapping.g.dart) to register bindings for symbol tree shaking.

Read the full file on GitHub · 219 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 219 lines · 61 tokens per session scan A 129ae526e854

Subscribe to this mod's changes

dart-use-ffigen is a skill published in the GitHub repository flutter/agent-plugins (2,895 stars, last pushed 4d ago), licensed BSD-3-Clause. It adds 61 tokens to every session and 2,684 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

orca-emulator-android

Control an Android emulator / device from inside Orca using the orca CLI. Use for listing/booting AVDs, taps, swipes, typing, hardware buttons (incl. Back and Recents), rotation, app install/launch, runtime permissions, the accessibility tree, and logcat — driving a real adb-connected device or emulator.…

stablyai/orca · 104 tokens

android-tombstone-symbolication

Symbolicate the .NET runtime frames in an Android tombstone file. Extracts BuildIds and PC offsets from the native backtrace, downloads debug symbols from the Microsoft symbol server, and runs llvm-symbolizer to produce function names with source file and line numbers. USE FOR triaging a .NET MAUI or Mono Android app…

dotnet/skills · 176 tokens

git-safety

Git safety rules. INVOKE WHEN: git push, force push, git reset, git clean, destructive git, push force, reset hard. NEVER force push or do destructive git operations.

tamagui/tamagui · 42 tokens

dogfood

Systematically explore and test a mobile app on iOS/Android with agent-device to find bugs, UX issues, and other problems. Use when asked to dogfood, QA, exploratory test, find issues, bug hunt, or test this app on mobile.

callstack/agent-device · 55 tokens

release

Cut a sim-use release end-to-end. Use when the user runs /release or asks to "ship a release", "publish a version", "cut a release", or "release to homebrew". Drives scripts/local-release.sh; never reimplement its build/sign/tarball logic.

lycorp-jp/sim-use · 61 tokens

android-pentest

安卓应用渗透测试 — APK分析、Hook、自动化测试、运行态驱动、签名恢复、抓包分析.

Netw0rkNoob/VulnClaw · 32 tokens