dart-modern-features

Guides writing and refactoring Dart code using modern language features from Dart 3.0 to 3.10.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/Wishtohear/bucket-water-oms --skill dart-modern-features-wishtohear
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-modern-features
Source: https://github.com/Wishtohear/bucket-water-oms/tree/main/bucket-water-oms-admin-mobile/tool/dart_skills_lint/.agents/skills/dart-modern-features
Command: npx skills add https://github.com/Wishtohear/bucket-water-oms --skill dart-modern-features-wishtohear

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Dart developers often write verbose, legacy-style code because they are unfamiliar with newer language features, leading to boilerplate classes, manual null checks, and non-exhaustive switch statements that the compiler cannot verify. ## Core Features & Use Cases - Modern Syntax Guidance: Provides avoid/prefer examples for Records, Pattern Matching, Switch Expressions, Sealed Classes, Extension Types, Wildcards, Null-Aware Elements, and Dot Shorthands. - Refactoring Support: Helps convert legacy Dart code into concise, idiomatic Dart 3.x code with compile-time safety guarantees like exhaustive matching on sealed class hierarchies. - Use Case: When reviewing a Flutter app's data layer, use this Skill to replace manual JSON field checks with pattern matching and convert multi-value return classes into records. ## Quick Start Review my Dart code and refactor it to use modern Dart 3 features like records, patterns, and switch expressions where appropriate.

Frequently Asked Questions about dart-modern-features

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

FAQPage Schema
How do I return multiple values from a function in Dart?▼

Use Records to bundle multiple values without defining a class, for example (String, int) fetchUser() returning ('Alice', 42). Access fields positionally with .$1 and .$2, avoiding boilerplate wrapper classes.

How to use pattern matching in Dart for JSON parsing?▼

Use if-case with map patterns to combine type checking, validation, and assignment in one statement, such as if (json case {'name': String name, 'age': int age}). This replaces manual containsKey and is-type checks.

What is the difference between sealed and abstract classes in Dart?▼

Sealed classes restrict subtypes to the same library, enabling the compiler to verify exhaustive switch expressions over all subtypes. Abstract classes allow unknown implementations anywhere, so the compiler cannot guarantee exhaustiveness.

When should I use extension types instead of wrapper classes in Dart?▼

Use extension types when you need type safety or domain-specific behavior without runtime allocation cost, since they compile down to the underlying type. Wrapper classes allocate new objects and are only needed for stateful behavior.

Which Dart version supports switch expressions and records?▼

Records, patterns, and switch expressions were introduced in Dart 3.0. Later additions like null-aware elements and dot shorthands arrive in subsequent releases up to Dart 3.10, so check your SDK version before adopting them.