freezed-patterns

Model immutable Flutter states with Freezed sealed classes and unions.

1|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill freezed-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: freezed-patterns
Source: https://github.com/dimitriRemoiville/cc-mobile/tree/main/plugins/cc-mobile-flutter/skills/freezed-patterns
Command: npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill freezed-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flutter teams can model immutable view states, events, and domain types using Freezed, reducing boilerplate and ensuring consistent equality.

Core Features & Use Cases

  • Sealed classes for view states and events (e.g., HomeState with idle, loading, ready, error) to enable exhaustive pattern matching.
  • Domain unions and immutable data classes with value equality to represent core business concepts.
  • CopyWith discipline and JSON serialization guidance to maintain safe, replaceable copies of data objects.
  • Practical guidance on when not to use freezed to avoid over-abstracting simple DTOs or entities.

Quick Start

Create a new sealed class with freezed for your feature and run build_runner to generate the code.

Frequently Asked Questions about freezed-patterns

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

FAQPage Schema
How do I model immutable state in Flutter using freezed?

Freezed models immutable state in Flutter by generating sealed classes, union types, and consistent equality, reducing boilerplate for view states and domain entities. It enables predictable pattern matching during UI and business logic flows.

How does freezed handle sealed classes and exhaustive pattern matching in Dart 3?

Freezed handles sealed classes in Dart 3 by generating union types that enforce exhaustive pattern matching. This ensures all possible view states or events are covered during switch statements, preventing missing cases.

Does freezed work with json_serializable and build_runner for Flutter projects?

Freezed works with json_serializable and build_runner to generate JSON serialization logic alongside immutable data classes. Running build_runner produces the code required for safe data parsing and copyWith functionality.

When should I not use freezed for Dart data classes?

You should not use freezed for simple DTOs or entities to avoid over-abstracting. It is best reserved for complex domain unions and view states where exhaustive pattern matching and strict immutability are required.

How do I manage state copies and equality with freezed in Flutter?

Freezed manages state copies and equality by generating copyWith methods and overriding equality operators. This allows you to safely replace data objects while maintaining consistent equality checks across your domain entities.