dart-3-updates

Applies Dart 3 patterns, records, and switch expressions to modernize Dart code.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-3-updates-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dart-3-updates
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/dart-3-updates
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-3-updates-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Pre-Dart-3 codebases rely on verbose if-else chains, wrapper classes for multiple return values, and non-exhaustive switch statements. This Skill provides the correct syntax and decision rules for adopting Dart 3 language features without introducing type-safety or exhaustiveness errors. ## Core Features & Use Cases - Branches and Exhaustiveness: Write switch statements, switch expressions, if-case constructs, and guard clauses with compile-time exhaustiveness checking via sealed classes and enums. - Patterns and Destructuring: Match and destructure maps, lists, records, and objects using the full pattern type system including logical-or, relational, null-check, and cast patterns. - Records vs Classes Guidance: Decide when to use records for multiple return values versus classes for reusable data models, with typedef best practices. - Use Case: When refactoring a legacy Flutter app, convert an abstract Result class hierarchy into a sealed class, replace if-else status handling with an exhaustive switch expression, and validate the result with dart analyze. ## Quick Start Refactor this if-else chain over my Status enum into an exhaustive Dart 3 switch expression and convert my Result hierarchy to sealed classes.

Frequently Asked Questions about dart-3-updates

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor if-else chains into Dart 3 switch expressions?

Replace the if-else chain with a switch expression using arrow syntax: final label = switch (status) { Status.loading => 'Loading...', _ => 'Error' }. Omit the case keyword, separate branches with commas, and use _ for the default branch.

When should I use records vs classes in Dart?

Use records for small one-time groupings like multiple return values where structural equality suffices. Use classes when the type is reused across files, needs methods or encapsulation, or is part of a public API requiring type-system enforcement.

How do sealed classes enable exhaustive switch in Dart?

Mark the base class as sealed so the compiler knows all subtypes. A switch over that sealed type then requires no default branch because Dart verifies every subtype is handled at compile time.

Does Dart 3 switch still require break statements?

No, Dart 3 switch statements do not require break. Each matched case body executes and jumps to the end automatically. Empty cases still fall through, and continue with a label enables non-sequential fallthrough.

How do I destructure JSON data with Dart patterns?

Use if-case with a map pattern: if (data case {'user': [String name, int age]}) { ... }. The pattern validates the structure and binds name and age as local variables scoped to the matching branch.