dart-use-pattern-matching
Skill3.1k starsChanged 5 days agoMPL-2.0View on GitHub
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.
6 other projects use a version of this, 4 of them edited; 4 of 4 edited versions we compared changed its rules; 1 new project in the last 4 weeks, against 1 the 4 before.
How people change it
4 of 4 edited versions changed its rules, and some changes recur.
Of the 4 edited versions we compared: 4 made changes of their own.
Rules people drop
- If handling polymorphic payloads or responses: Use
switchexpressions over map discriminant keys to deserialize intosealedclass hierarchies.dropped by 4 of 4 - If unpacking multiple fields from an object or
MapEntry: Use Object patterns (final Spec(:field1, :field2!) = spec;,for (final MapEntry(:key, :value) in map.entries)) when promoting nullable properties or unpacking 3+ fields used across multiple …dropped by 4 of 4 - When checking or promoting a single variable, use standard
ischecks instead ofif-casepatterns that introduce shadow aliases.dropped by 4 of 4 - When mapping or returning values where both
nulland a typeTare valid and handled identically, match the nullable typeT?directly rather than creating redundantnullarms.dropped by 4 of 4 - Do not use
if-casein loops or deserialization to filter elements if malformed data should trigger an error or diagnostic warning.dropped by 4 of 4 - Use
if (x is T)instead of aswitchstatement with only 1 case anddefault: break;.dropped by 4 of 4 - Use standard conditional ternary operators (
condition ? a : b) instead ofswitch (condition) { true => a, false => b }.dropped by 4 of 4 - Use object or record destructuring when extracting 3+ fields used across multiple statements, iterating
MapEntry(:key, :value)inmap.entriesloops, eliminating a single-use intermediate variable, or promoting nullable fields to local variables (:field!…dropped by 4 of 4
Rules people add
- A rule we can't quote: its licence doesn't allow itadded by 4 of 4
We split this file and each edited version into the rules they give an agent and match them by wording. A version that adds no rule of its own and has not changed since this file last did reads as an older text, so what it lacks is not counted as dropped. We keep no past texts of a file, so that is inferred, and an edited version that started from an older text still counts its gaps as drops.
Adopted by
Steady: 1 new project took it in the last 4 weeks, 1× the 4 weeks before.thin data
Most recently taken up by
- dart-lang/skillsword for word, first seen Oct 16, 2026
- zhouycheng/skillsedited, first seen Oct 13, 2026
- enrique-lozano/Monekinedited, first seen Oct 9, 2026
- flutter/skillsword for word, first seen Oct 8, 2026
- hjdspace/SpaceCodeedited, first seen Jul 21, 2026
- RodotDev/arb_aiedited, first seen May 30, 2026
Who's talking about deretame/Breeze
- deretame/homebrew-Breeze“fix(cask): 下载地址补上 v 前缀,修复 brew install 404”GitHub · Nov 9, 2026
- 1Password/for-open-source“Application for [Breeze]”GitHub · Oct 9, 2026
- LuckyLxi/Hazuki“[Feature]: 聚合搜索”GitHub · Jun 21, 2026
- breeze-project-org/Breeze“哔咔登录、阅读疑似不走 SOCKS5 代理”GitHub · Feb 20, 2026
- breeze-project-org/Breeze“哔咔漫画无法下载”GitHub · Oct 5, 2025
The biggest 5 of 5 mentions linking to the repository that our crawl found. Each line is their own headline.
Other versions6 projects use a version of this.
Word for word · 2
- flutter/skills★ 3.2k100% same
- dart-lang/skills★ 548100% same
Edited · 4
- enrique-lozano/Monekin★ 26875% same
- hjdspace/SpaceCode★ 475% same
- RodotDev/arb_ai★ 175% same
- zhouycheng/skills★ 175% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- dart-add-unit-testSkill
- dart-build-cli-appSkill
- dart-collect-coverageSkill
- dart-fix-runtime-errorsSkill
- dart-generate-test-mocksSkill
- dart-migrate-to-checks-packageSkill
- dart-resolve-package-conflictsSkill
- dart-run-static-analysisSkill
- dart-setup-ffi-assetsSkill
- dart-use-doc-examplesSkill
- dart-use-ffigenSkill
- dart-use-path-packageSkill
- dart-use-primary-constructorsSkill
- dart-write-documentationSkill
- easy-refresh-indicatorsSkill
- easy-refresh-nested-scrollSkill
- easy-refresh-usageSkill
- flutter-add-integration-testSkill
- flutter-add-widget-previewSkill
- flutter-add-widget-testSkill
- flutter-apply-architecture-best-practicesSkill
- flutter-build-responsive-layoutSkill
- flutter-fix-layout-issuesSkill
- flutter-implement-json-serializationSkill
- flutter-setup-declarative-routingSkill
- flutter-setup-localizationSkill
- flutter-use-http-packageSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
26 rules. 6 are common, 0 are distinctive, and 20 are very specific to this project.
6
Common
Most of the 4 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
20
Very specific
Tied to their project's names, files or tools. Probably skip.
Licensed with conditions — read it at the source. We count its rules but don't quote them. Read them on GitHub.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

