dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing…
Applies Dart 3 pattern matching, switch expressions, and destructuring idiomatically to validate data schemas, handle algebraic data types, and decompose control flow. Use when refactoring complex if-else chains, parsing polymorphic JSON or API responses, destructuring Lists,
Claude Code
$ npx -y skills add flutter/agent-plugins --skill dart-use-pattern-matching --agent claude-code
Codex
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a codex -y
Cursor
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a cursor -y
Gemini CLI
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a gemini-cli -y
GitHub Copilot
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a github-copilot -y
OpenCode
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a opencode -y
Windsurf
$ npx skills add flutter/agent-plugins --skill dart-use-pattern-matching -a windsurf -y
name: dart-use-pattern-matching description: >- Applies Dart 3 pattern matching, switch expressions, and destructuring idiomatically to validate data schemas, handle algebraic data types, and decompose control flow. Use when refactoring complex if-else chains, parsing polymorphic JSON or API responses, destructuring Lists, URI/path segments, String.split() tokens, Records, or Maps, or enforcing exhaustiveness on sealed classes. Don't use for simple boolean conditions, single-variable type promotion (use `is`), or basic collection filtering. metadata: model: models/gemini-3.1-pro-preview last_modified: Tue, 13 Oct 2026 19:45:00 GMT
Apply specific pattern types based on the data structure and desired outcome. Follow these conditional guidelines:
Select the appropriate switch construct based on the execution context:
Implement patterns using the following syntax and rules:
Pattern matching and switch expressions should simplify code, not add syntactic overhead. Observe the following boundaries:
When checking or promoting a single variable, use standard `is` checks instead of `if-case` patterns that introduce shadow aliases.
// ✅ Promotes `key` directly in-place without extra variables
for (final MapEntry(:key, :value) in map.entries) {
if (key is String && value != null) {
process(key, value);
}
} // ❌ Anti-pattern: Introduces unnecessary alias variable `k`
for (final MapEntry(:key, :value) in map.entries) {
if (key case final String k when value != null) {
process(k, value);
}
}When mapping or returning values where both `null` and a type `T` are valid and handled identically, match the nullable type `T?` directly rather than creating redundant `null` arms.
// ✅ Clean nullable pattern match
switch (value) {
final String? s => s,
_ => throw FormatException('Invalid value: $value'),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.