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 619 stars 60 forks Updated today MIT

Install

View on GitHub

Quality Score: 95/100

Stars 20%
93
Recency 20%
100
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
today
Language
Shell
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

Code & Development Listed

dart3-idioms-and-coding-standards

Enforces which Dart 3 construct each declaration earns — sealed class + exhaustive switch with no `default:`/`case _:`, the three class modifiers (`sealed`/`final`/`abstract interface class`) and skip the rest, records as intra-layer tuples only, immutable value types (`final` fields, `const` ctor, value equality) hand-rolled when trivial and `freezed` when boilerplate dominates, explicit stable identity, total non-throwing domain functions, make-illegal-states-unrepresentable, and firm method/build/file/nesting complexity limits (the single-source-of-truth table other skills cite) — while banning `late`/`!`/`dynamic` honesty dodges. Use when authoring or reviewing any Dart type or declaration: class vs enum vs record vs typedef, hand-rolled vs `freezed`, adding a `switch`/`if-case`, writing `copyWith` or `==`/`hashCode`, deciding identity, keeping a domain function total, or hitting a length/nesting limit.

0 Updated 2 weeks ago
zakariaf
Code & Development Listed

dart

Dart 3.x language standards and code quality conventions. Use when writing or reviewing any Dart code — null safety, patterns, sealed classes, records, class modifiers, naming, immutability, collections, async, and import organisation.

2 Updated 2 weeks ago
ndisisnd
AI & Automation Featured

effective-dart

Use when writing Dart code, reviewing for style, refactoring naming, adding doc comments, structuring imports, or enforcing type annotations.

619 Updated today
evanca