dart-use-pattern-matching

Installation
SKILL.md

Contents

Pattern Selection Strategy

Apply distinct pattern matching strategies based on the target data structure:

  • JSON Validation and Destructuring: Use Map and List patterns to simultaneously validate nested shapes and bind values to local variables in a single step.
  • Multiple Returns: Return Records from functions and use Record patterns to destructure named or positional values directly into scoped variables.
  • Algebraic Data Types (ADTs): Combine sealed class hierarchies with Object patterns in switch expressions to benefit from compile-time exhaustiveness checking.
  • Numeric Ranges and logical Checks: Combine relational patterns (>=, <, etc.) and logical-and (&&) or logical-or (||) operators within switch cases.
  • Guard Clauses: Use the when keyword to assert dynamic conditions that cannot be expressed purely through static patterns.

Switch Expressions vs Switch Statements

Installs
6
GitHub Stars
20
First Seen
13 days ago
dart-use-pattern-matching — dhruvanbhalara/skills