dart-3-updates

Featured

Use when writing switch statements, refactoring if-else chains, creating data classes, choosing records vs classes, destructuring values, or modernizing pre-Dart-3 code.

AI & Automation 643 stars 66 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
94
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Dart 3 Updates Skill Apply Dart 3 language features — branches, patterns, pattern types, and records — correctly and idiomatically. ## When to Use Use this skill when: * Writing or refactoring `switch` statements or `if-else` chains. * Creating new data-holding classes and deciding between sealed classes, records, or plain classes. * Destructuring values from maps, lists, records, or objects. * Modernizing pre-Dart-3 code to use patterns, exhaustiveness checks, or switch expressions. --- ## 1. Branches ### if / if-case ```dart // Standard if if (score >= 90) { grade = 'A'; } else if (score >= 80) { grade = 'B'; } else { grade = 'C'; } // if-case: match and destructure against a single pattern if (pair case [int x, int y]) { print('$x, $y'); } ``` - `if` conditions must evaluate to a `bool`. - In `if-case`, variables declared in the pattern are scoped to the matching branch. - If the pattern does not match, control flows to the `else` branch (if present). ### switch statements ```dart switch (command) { case 'quit': quit(); case 'start' || 'begin': // logical-or pattern startGame(); default: print('Unknown command'); } ``` - Each matched `case` body executes and jumps to the end — `break` is **not required**. - Non-empty cases can end with `continue`, `throw`, or `return`. - Use `default` or `_` to handle unmatched values. - Empty cases fall through; use `break` to prevent fallthrough in an empty case. - Use `continue` with a label for ...

Details

Author
evanca
Repository
evanca/flutter-ai-rules
Created
1 years ago
Last Updated
1 weeks ago
Language
Shell
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category