finds.dev

rrousselGit/freezed

Code generation for immutable classes that has a simple syntax/API without compromising on the features.

View on GitHubHomepage ↗

★ 2,182Dartupdated Jun 2026

// the take

Freezed is a Dart/Flutter code generator that eliminates the boilerplate of writing immutable data classes — `toString`, `==`, `hashCode`, `copyWith`, and JSON serialization. It also handles sealed union types with proper pattern matching support. If you're writing Flutter apps with anything resembling a model layer, you'll use this or reinvent it poorly.

The deep copy syntax (`company.copyWith.director.assistant(name: 'John')`) is genuinely clever — it solves nested immutable updates without the usual pyramid of `copyWith` calls. Union/sealed class support integrates directly with Dart 3's native pattern matching rather than fighting it. The split between `freezed` (dev dependency, code generator) and `freezed_annotation` (runtime dependency) is the right architecture — you're not shipping the generator to production. Test suite coverage is thorough: separate integration files per feature, bidirectional tests, regression cases.

The `part` file requirement is a build_runner tax that pollutes every file and makes the initial setup annoying — you get confusing errors until you've run `dart run build_runner watch` at least once. Adding methods to primary-constructor classes requires a private empty constructor (`const Person._()`) that's a non-obvious gotcha and trips up almost everyone the first time. The JSON union type discrimination relies on a `runtimeType` key in the payload by default, which will silently fail or produce wrong types if you're consuming an API that uses a different discriminator field. Generated `.freezed.dart` files are verbose and large; in big projects, they slow down the analyzer noticeably.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
2,182
Forks
301
Language
Dart
Last commit
28 Jun 2026

// nearby

If freezed isn't quite it.

All repos →