Sponsored byOutsenseAI that finds your next clients
SponsorGROUOutbound, LinkedIn content and leads for B2B teamsSponsorOutsenseAI that finds your next clientsAd+Your tool hereSeen by people installing AI tools@Weekly picksThe best new tools, one email a week

dart-use-pattern-matching

Skill by flutter

Applies Dart 3 pattern matching, switch expressions, and destructuring to validate JSON, handle sealed class hierarchies, and simplify control flow. Built for Dart developers refactoring if-else chains or parsing polymorphic API responses.

  • Score 94
  • 3.2k stars
  • BSD-3-Clause
  • Updated
Works withClaude CodeClaude apps Antigravity CLI

Install dart-use-pattern-matching

Built from the published package, never by AI.

git clone --depth 1 https://github.com/flutter/agent-plugins /tmp/agent-plugins && mkdir -p ~/.claude/skills && cp -r /tmp/agent-plugins/skills/dart-use-pattern-matching ~/.claude/skills/dart-use-pattern-matching

Run in your terminal. Claude Code loads skills from ~/.claude/skills automatically.

Step-by-step: install dart-use-pattern-matching in Claude Code

Skills can run scripts on your machine. Some need an API key: check the README.

About

This agent skill guides an AI assistant in using Dart 3 pattern matching, switch expressions, and destructuring. It covers validating deserialized JSON with Map and List patterns, handling sealed class hierarchies with exhaustive switches, and destructuring Records, URI path segments, and String.split() tokens. The skill includes a pattern selection strategy, anti-pattern guidance, and feedback loops that use dart analyze.

It is aimed at Dart developers who refactor complex if-else chains or parse polymorphic JSON or API responses. The skill also tells the assistant when not to use patterns, such as simple boolean conditions, single-variable type promotion where is is simpler, or basic collection filtering. It links to an executable example, examples/json_patterns.dart, for tagged API response parsing.

Written from the project's SKILL.md and checked against it.

What it can do

  • Pattern selectionChooses Map, List, Object, or Record patterns based on the shape of the data.
  • Switch expressionsProduces values with exhaustive switch arms over sealed classes.
  • Polymorphic JSON parsingDeserializes tagged JSON payloads into sealed class hierarchies.
  • Path and token destructuringMatches URI segments and String.split() results with rest elements.
  • Record and object destructuringUnpacks multiple fields into local variables in one declaration.
  • Fast-fail validationThrows explicit errors for malformed items instead of silently skipping them.

What you need

  • Dart 3 or later
  • Dart analyzer (dart analyze)

Try asking

  • Refactor this if-else chain into a Dart 3 switch expression.
  • Parse this tagged JSON API response into a sealed class hierarchy.
  • Destructure these URI path segments with a Dart list pattern.

Good to know

  • Not for simple boolean conditions, single-variable type promotion, or basic collection filtering.
  • Map patterns check key existence, so an omitted key fails to match even if its type is nullable.

Security check

A

No download-and-run commands, hidden instructions or signs of sending keys out were found.

Checked automatically: skills/dart-use-pattern-matching/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work

Inside the skill

  • SKILL.md13 KB
  • examples/json_patterns.dart3 KB

Alternatives to dart-use-pattern-matching

All alternatives →
openclaw-github-repo-commandersickn33
94

Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.

AAA Skill 50k
gradiogradio-app
94

Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.

AAA Skill 44k
hig-components-menussickn33
94

Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.

AAA Skill 50k
fastapi-templateswshobson
94

Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.

AAA Skill 43k
appfunctionsandroid
94

Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.

AAA Skill 11k
agent-qa-authoringsickn33
94

Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.

AAA Skill 50k

Compare with openclaw-github-repo-commander, gradio or hig-components-menus

dart-use-pattern-matching: common questions

When should I not use Dart pattern matching?

The skill says not to use it for simple boolean conditions, for single-variable type promotion where is is simpler, or for basic collection filtering.

Why might an optional JSON key fail to match a map pattern?

Map patterns check for key existence with containsKey. A key omitted from the payload fails to match even if its type is nullable, so the skill suggests reading it with map['key'] as String?.

How does the skill avoid silently dropping malformed data?

It recommends throwing a FormatException for unexpected items instead of using if-case in loops, which would silently skip them.

How do I install dart-use-pattern-matching?

Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.

Is dart-use-pattern-matching free?

The code is published under the BSD-3-Clause licence. The service it connects to may have its own pricing.

Is dart-use-pattern-matching safe to use?

It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.

What are alternatives to dart-use-pattern-matching?

Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.

dart-use-pattern-matching Install

Add to stack

Loading.