dart-3-updates

Modernize Dart code with Dart 3 switch expressions, records, and sealed classes.

2|Updated Aug 13, 2023
One-click install
npx skills add https://github.com/NNPopov/movie-theater-tickets --skill dart-3-updates-nnpopov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dart-3-updates
Source: https://github.com/NNPopov/movie-theater-tickets/tree/main/src/clients/.claude/skills/dart-3-updates
Command: npx skills add https://github.com/NNPopov/movie-theater-tickets --skill dart-3-updates-nnpopov

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers modernize Dart code by replacing older branching and data-handling styles with Dart 3 features that are clearer, safer, and easier to maintain.

Core Features & Use Cases

  • Switch Modernization: Refactor if-else chains into switch statements and switch expressions with exhaustive handling.
  • Pattern Matching: Destructure lists, maps, records, and objects using if-case, guards, and nested patterns.
  • Data Modeling Guidance: Choose between records, classes, and sealed hierarchies for reusable, type-safe data structures.
  • Migration Support: Update pre-Dart-3 codebases to use idiomatic patterns, logical-or cases, and null-aware matching.

Quick Start

Use this skill to refactor the attached Dart code into Dart 3 idioms with exhaustive switches, patterns, and records.

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 switch expressions in Dart 3?

To refactor if-else chains into switch expressions in Dart 3, replace conditional branching with switch statements and switch expressions using exhaustive handling and logical-or cases for clearer logic.

What is the best way to model data using Dart 3 sealed classes and records?

Modeling data with Dart 3 sealed classes and records involves choosing between reusable type-safe data structures, leveraging sealed hierarchies for exhaustive matching, and using records for structured value destructuring.

How do I destructure lists and maps using Dart 3 pattern matching?

Destructuring lists, maps, records, and objects in Dart 3 uses pattern matching with if-case statements, guards, and nested patterns to bind values directly and simplify complex data extraction.

Can I migrate a pre-Dart-3 codebase to use idiomatic Dart 3 patterns?

Migrating a pre-Dart-3 codebase to idiomatic Dart 3 patterns involves updating branching styles and data handling to use null-aware matching, exhaustive switches, and logical-or cases for safer maintainability.

When should I use sealed classes instead of records for data modeling in Dart 3?

Use sealed classes instead of records for data modeling in Dart 3 when you need exhaustive type hierarchies for exhaustive matching, whereas records suit simple, structured value destructuring without subtyping.