Code generation for immutable data classes and unions in Dart
open sourceMITfree
Freezed is a code generator for Dart and Flutter that writes the boilerplate of data classes for you: from a short class definition it generates the constructor and properties, toString, == and hashCode, a deep copyWith, and JSON serialization through json_serializable. It also supports union types (sealed classes) with pattern matching, default values, asserts and mutable classes when you ask for them. You add freezed and freezed_annotation to a project and run build_runner. It's by Remi Rousselet, under the MIT licence.
Problems it solves
- stop writing copyWith, == and hashCode by hand for my Flutter model classes
- immutable data classes in Dart with JSON serialization
- sealed union types for app state in Flutter
Features
- generates ==, hashCode, toString and copyWith for Dart classes
- union types (sealed classes) with pattern matching
- JSON serialization through json_serializable
- deep copy with nested copyWith
- lint package freezed_lint
Alternatives
The same job
These do what Freezed does.
- equatable A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode
- built_value Immutable value types, enum classes and JSON serialization for Dart, by code generation
