dart-use-ffigen

Generates Dart FFI bindings from C headers using package:ffigen.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-use-ffigen-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dart-use-ffigen
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/dart-use-ffigen
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-use-ffigen-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ffigen.

What problem does it solve? Hand-written Dart FFI bindings are error-prone, brittle, and block native asset tree shaking. This Skill automates binding generation with package:ffigen so C, Objective-C, and Swift integrations stay correct and maintainable. ## Core Features & Use Cases - Automated Binding Generation: Builds a programmatic FfiGenerator script at tool/ffigen.dart that parses native headers and emits Dart bindings. - Tree Shaking Support: Configures recordUse and recordUseMapping outputs so unused native symbols can be stripped at link time. - Conventions & Verification: Enforces output under lib/src/third_party/ with .g.dart extensions, license preambles, targeted inclusion filters, and dart analyze validation. - Use Case: When adding a binding for sqlite3_libversion from third_party/sqlite/sqlite3.h, generate lib/src/third_party/sqlite3.g.dart automatically instead of writing manual DynamicLibrary lookups. ## Quick Start Generate FFI bindings for the native headers in this package using package:ffigen and verify the result with dart analyze.

Frequently Asked Questions about dart-use-ffigen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate Dart FFI bindings from C headers?

Create a generator script at tool/ffigen.dart that configures FfiGenerator with your header entry points, function inclusion filters, and output paths, then run dart run tool/ffigen.dart. Add ffigen as a dev dependency first with dart pub add dev:ffigen.

Should I write dart:ffi bindings manually or use ffigen?

Use ffigen whenever native headers exist or are generated by a build step. Manual DynamicLibrary.lookup and @Native declarations are error-prone, brittle across ABI changes, and lack the recordUse metadata needed for symbol tree shaking.

Does ffigen support tree shaking of native symbols?

Yes. Set recordUse to (_) => true under Functions and specify a recordUseMapping output file ending in .g.dart under lib/src/third_party/. This registers bindings so link-time tree shaking can strip unused native symbols.

Where should generated ffigen binding files be placed?

Generated bindings that interface with third-party libraries must go under lib/src/third_party/ and use the .g.dart extension, such as sqlite3.g.dart. The generator script itself belongs at tool/ffigen.dart in the package root.

Why does dart analyze report warnings in generated ffigen files?

Generated code often triggers lints like camel_case_types or non_constant_identifier_names. Fix this by adding the warning codes to the ignore_for_file list in the generator's preamble configuration rather than editing the generated file or global lint rules.

What should I do when ffigen output has compile errors?

Do not edit the generated file manually. Report the analyzer error details to the user and direct them to file an issue on the dart-lang/native repository, since errors in generated bindings indicate a generator or header parsing problem.