dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing…
Guides agents in compiling and packaging C/C++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via hook/build.dart and hook/link.dart utilizing package:hooks and package:native_toolchain_c). Use when a user asks to: 'setup
Claude Code
$ npx -y skills add flutter/agent-plugins --skill dart-setup-ffi-assets --agent claude-code
Codex
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a codex -y
Cursor
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a cursor -y
Gemini CLI
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a gemini-cli -y
GitHub Copilot
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a github-copilot -y
OpenCode
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a opencode -y
Windsurf
$ npx skills add flutter/agent-plugins --skill dart-setup-ffi-assets -a windsurf -y
name: dart-setup-ffi-assets description: "Guides agents in compiling and packaging C/C++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via hook/build.dart and hook/link.dart utilizing package:hooks and package:native_toolchain_c). Use when a user asks to: 'setup native assets', 'compile C/C++ source code', 'bundle dynamic libraries', 'build native C code', 'link native assets', 'implement build.dart or link.dart hooks', or 'integrate C/C++ interop in Dart/Flutter'. Helps agents avoid manual toolchain orchestration and configures secure hash-validated binary downloads or advanced linker tree-shaking with package:record_use mapping." metadata: model: models/gemini-3.1-pro-preview last_modified: Fri, 29 May 2026 09:10:00 GMT
Integrate and automate the compilation and packaging of native C/C++ source code into **Code Assets** under Dart's overarching **Native Assets** feature using build and link hooks.
---
Under Dart's **Native Assets** feature, packages can package native code (like C/C++ libraries) as **Code Assets** and bundle them automatically during standard development cycles (e.g., `dart run`, `dart test`, `dart build`, and `flutter run`). The packaging of **Code Assets** is driven by two programmatic hook scripts placed inside a package's `hook/` folder:
1. `hook/build.dart`: Compiles local C sources to machine code or bundles prebuilt native binaries as code assets for a specific host/target architecture. 2. `hook/link.dart`: Links built code assets, applying advanced tree-shaking optimizations to strip unused native symbols and compress the runtime binary size.
---
> [!IMPORTANT] > Keep all file resolving platform-independent. Never hardcode absolute target paths, shell scripts, or system command variables. Always use `Platform.script.resolve()` or `Uri`-based resolution to ensure scripts are fully portable.
---
Programmatic build and link hooks for **Code Assets** leverage three specialized native interop packages:
| Dependency | Purpose | Key API Abstractions | | :--- | :--- | :--- | | **`package:hooks`** | Main orchestrator defining execution bounds. | `build(args, callback)`, `link(args, callback)` | | **`package:native_toolchain_c`** | Detects local compilers (MSVC, Xcode/Clang, GCC) and executes build toolchains. | `CLibrary`, `CBuilder`, `LinkerOptions.treeshake` | | **`package:code_assets`** | Models code metadata records passed to dynamic loaders. | `CodeAsset`, `DynamicLoadingBundled` |
---
Add Code Assets hook and toolchain dependencies to your package. You must fetch these dependencies directly from **pub.dev**.
You can add it automatically using the CLI:
dart pub add code_assets hooks native_toolchain_c record_use dev:ffigen
Or manually declare them in your target package's `pubspec.yaml`:
dependencies: code_assets: ^1.0.0 hooks: ^0.1.0 native_toolchain_c: ^0.1.0 record_use: ^0.6.0 dev_dependencies: ffigen:
Agent plugins for Flutter, maintained by the Flutter team. A collection of plugins designed to extend AI agent capabilities for Flutter development.
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing…
Architectural patterns, entrypoint structure, exit codes, stream routing, and subprocess spawning for Dart command-line interface…
Collect coverage using the coverage packge and create an LCOV report
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via…
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing…
Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.