NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
pub.dev · #242 most downloaded on pub.dev
Code generation for immutable classes that has a simple syntax/API without compromising on the features.
Last release 20 days ago
18 Sep 2026
Ships fairly regularly
a new release about every 2 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
7 years old
146 releases · first in 2020
One column per quarter.
freezed : 4.0.1 -> 4.0.2
freezed : 4.0.1 -> 4.0.2
this/super fields and optional positional argument gaps in primary-constructor copyWith methods.super arguments when generating properties and report required non-cloneable arguments before generating invalid code.freezed : 4.0.0 -> 4.0.1
freezed : 4.0.0 -> 4.0.1
@overrides in class fields and primary constructors.Fix ==/copyWith when immutable collections are enabled yet non-factory constructors are used.
==/copyWith when immutable collections are enabled yet non-factory constructors are used.(int,) records incorrectly generatedfinal keyword inside constructor parameter. This is due to Dart 3.13 no-longer allowing this syntax.
This prevents @unfreezed from defining immutable fields.fix: correct immutable collection handling in == and copyWith for non…
fix: correct immutable collection handling in == and copyWith for non…
==/copyWith when immutable collections are enabled yet non-factory constructors are used.Fix (int,) records incorrectly generated
(int,) records incorrectly generated_Breaking_: No-longer support final keyword inside constructor parameter. This is due to Dart 3.13 no-longer allowing this syntax. This prevents @unfr
final keyword inside constructor parameter. This is due to Dart 3.13 no-longer allowing this syntax.
This prevents @unfreezed from defining immutable fields.freezed : 3.2.5 -> 3.2.6-dev.1
freezed : 3.2.4 -> 3.2.5
Support analyzer 9.0.0
Support analyzer 9.0.0
freezed : 3.2.2 -> 3.2.3 freezed_lint : 0.0.11 -> 0.0.12
freezed : 3.2.2 -> 3.2.3
freezed_lint : 0.0.11 -> 0.0.12
freezed : 3.2.1 -> 3.2.2
Support latest analyzer/source_gen
Support latest analyzer/source_gen
Support Dart 3.8.0 and analyzer 7.5.9 as a minumum.
build 3.0.0-dev.source_gen 3.0.0-dev.Stop writing // dart format width=80 to the generated freezed files.
when/map back// dart format width=80 to the generated freezed files.Remove logs
Remove logs
Fix ==/hashCode when using inheritance. The generated ==/hashCode now call super == other when necessary.
super == other when necessary.Diagnosticable and toStringUpdate docs (thanks to @lishaduck)
Update readme (thanks to @snapsl)
Update readme (thanks to @snapsl)
Throw when using extends/with but not specifying a MyClass._() constructor
extends/with but not specifying a MyClass._() constructorwith _$MyClassMyClass._() when they define getters/methods/...Fix a bug with diagnosticable objects.
Fix a bug with diagnosticable objects.
Freezed 3.0 is about supporting a "mixed mode". From now on, Freezed supports both the usual syntax:
Freezed 3.0 is about supporting a "mixed mode".
From now on, Freezed supports both the usual syntax:
@freezed
sealed class Usual with _$Usual {
factory Usual({int a}) = _Usual;
}
But also:
@freezed
class Usual with _$Usual {
Usual({this.a});
final int a;
}
This has multiple benefits:
factory syntaxThis also offers a way to use all constructor features, such as initializers
or super():
class Base {
Base(String value);
}
@freezed
class Usual extends Base with _$Usual {
Usual({int? a}) a = a ?? 0, super('value');
final int a;
}
When using Freezed, a common problem has always been the lack of extends support and non-constant default values.
Besides through "Mixed mode" mentioned above, Freezed now offers a way for factory constructors to specify non-constant defaults and a super(), by
relying on the MyClass._() constructor:
It also has another benefit:
Complex Unions now have a way to use Inheritance and non-constant default values,
by relying on a non-factory MyClass._() constructor.
For context:
Before, when a Freezed class specified a property or method,
it was required to specify a MyClass._() constructor:
@freezed
class Example with _$Example {
// Necessary for helloWorld() to work
Example._();
factory Example(String name) = _Example
void helloWorld() => print('Hello $name');
}
However, that Example._() constructor was required to have no parameter.
Starting Freezed 3.0, this constructor can accept any parameter.
Freezed will then pass its values from other factory constructors, based on name.
In short, this enables extending any class:
class Subclass {
Subclass.name(this.value);
final int value;
}
@freezed
class MyFreezedClass extends Subclass with _$MyFreezedClass {
// We can receive parameters in this constructor, which we can use with `super.field`
MyFreezedClass._(super.value): super.name();
factory MyFreezedClass(int value, /* other fields */) = _MyFreezedClass;
}
It also enables non-constant default values:
@freezed
sealed class Response<T> with _$Response<T> {
// We give "time" parameters a non-constant default
Response._({DateTime? time}) : time = time ?? DateTime.now();
// Constructors may enable passing parameters to ._();
factory Response.data(T value, {DateTime? time}) = ResponseData;
// If ._ parameters are named and optional, factory constructors are not required to specify it
factory Response.error(Object error) = ResponseError;
@override
final DateTime time;
}
Along with the mixed mode, it is also possible to eject a "union" case, by having it point to a custom class.
Concretely, you can do:
@freezed
sealed class Result<T> with _$Result {
Result._();
// Data does not exist, so Freezed will generate it as usual
factory Result.data(T data) = ResultData;
// We wrote a ResultError class in the same library, so Freezed won't do anything
factory Result.error(Object error) = ResultError;
}
// We manually wrote `ResultError`
class ResultError<T> extends Result<T> {
ResultError(this.error): super._();
final Object error;
}
This combines nicely with "Mixed mode" mentioned previously, as extracted union cases can also be Freezed classes:
// Using freezed with a simple class:
@freezed
class ResultError<T> extends Result<T> {
ResultError(this.error): super._();
final Object error;
}
// Or using a factory:
@freezed
class ResultError<T> extends Result<T> {
ResultError._(): super._();
factory ResultError(Object error) = _ResultError;
}
This feature offers fine-grained control over every parts of your models.
Note:
Unfortunately, it is kind of required to "extend" the parent class (so here extends Result<T>). This is because Dart doesn't support sealed mixin class, so you can't do
with Result<T> instead.
map/when and variants. These have been discouraged since Dart got pattern matching.abstract, sealed, or manually implements _$MyClass.// dart format off. This
prevents having to exclude generated file from formatting check in the CI.@freezed
sealed class Result<T> with _$Result {
// It wasn't possible to write _data before, but now is.
factory Result._data(T data) = ResultData;
factory Result.error(Object error) = ResultError;
}
Nothing published for this version
Support analyzer 7.0.0
Support analyzer 7.0.0
freezed_annotation upgraded to 2.4.4
freezed_annotation upgraded to 2.4.4Generate documentation for copyWith (thanks to @rekire)
copyWith (thanks to @rekire)Stop using JsonKey(ignore: true) in favour of JsonKey(includeFromJson: false, includeToJson: false) (thanks to @lrsvmb)
JsonKey(ignore: true) in favour of JsonKey(includeFromJson: false, includeToJson: false)
(thanks to @lrsvmb)- Require Dart >=3.0.0 - Support latest collection
collection- Support analyzer 6.5.0
Fixed copyWith(value: null) when using nullable generics
copyWith(value: null) when using nullable genericsFixed @freezed no-longer working inside part of files.
@freezed no-longer working inside part of files.Added format: false flag in the build.yaml, to disable formatting in generated files. This can significantly improve performance, but may require upda
format: false flag in the build.yaml, to disable formatting
in generated files.
This can significantly improve performance, but may require updating your
CI to not check that generated files are formatted.InconsistentAnalysisException- Fixed a performance problem
Fixed broken link in docs (thanks to @iDevOrz)
Have the == implementation use Object as parameter instead of dynamic
== implementation use Object as parameter instead of dynamicLoosened analyzer version to support both ^5.13.0 and ^6.0.0 (thanks to @SunlightBro)
Loosened analyzer version to support both ^5.13.0 and ^6.0.0 (thanks to @SunlightBro)
Do not throw on unresolved annotations.
Do not throw on unresolved annotations.
Fix lowercase warning on generated objects.
- Support analyzer 6.0.0
freezed_annotation upgraded to 2.3.0
freezed_annotation upgraded to 2.3.0Allow enabling/disabling all when/map variants at once (thanks to @gaetschwartz)
when/map variants at once (thanks to @gaetschwartz)Fix regression in analyzer 5.13.0 (thanks to @SunlightBro)
Fix deprecated warning with analyzer 5.12.0 (thanks to @SunlightBro)
abstractFixed an issue with the generated code when classes contains a $ in their property/constructor/class name (thanks to @medz)
$ in
their property/constructor/class name (thanks to @medz)Fix more issues with copyWith
Fix more issues with copyWith
Fix various issues with copyWith
Fix various issues with copyWith
Union types now expose properties with the same name but different type on the shared interface. (Thanks to @DevNico)
Union types now expose properties with the same name but different type on the shared interface. (Thanks to @DevNico)
This allows doing:
@freezed
class Union with _$Union {
factory Union.first(int value) = _UnionFirst;
factory Union.second(double value) = _UnionSecond;
}
void main() {
Union union;
num value = union.value;
// No need for casting as "num" is the shared interface between int/double
}
Fixes copyWith not working with null on some scenarios.
Fixes a stackoverflow error when continuously passing unmodifiable collections as parameter to freezed classes
fix: Deep copy now correctly handles cases where a property is a Freezed class with disabled copyWith
Upgrade analyzer
Upgrade analyzer
The generated copyWith is now annotated by @useResult (thanks to @miDeb)
copyWith is now annotated by @useResult (thanks to @miDeb)copyWith (thanks to @miDeb)mapOrNull/whenOrNull (thanks to @DevNico)@With.fromString and @Implements.fromString to allow unions
to implement generic types. (thanks to @rorystephenson)DeepCollectionEquality (thanks to @knaeckeKami)Fix an issuee where Freezed fails to detect that the Diagnosticable API is available
Diagnosticable API is availableImprove pub score
Improve pub score
Add support for de/serializing generic Freezed classes (Thanks to @TimWhiting)
exports (Thanks to @TimWhiting)Increase minimum analyzer version.
Increase minimum analyzer version.
Fixes a bug where using @unfreezed on unions somehow still generated immutable properties.
Fixes a bug where using @unfreezed on unions somehow still generated immutable properties.
Update warning message when using abstract freezed classes
Update warning message when using abstract freezed classes
fix: performance regression with ==/hashCode/copyWith due to immutable collections
Fixed invalid generated code when defining nullable collections.
Fixed invalid generated code when defining nullable collections.
Fixed a bug where the generated when/map methods were potentially invalid when using default values
Breaking: freezed_annotation no-longer exports the entire package:collection
Breaking: freezed_annotation no-longer exports the entire package:collection
Breaking: Freezed no-longer generates $MyClassTearOff. This feature is now available in Dart
Breaking Removed @Freezed(maybeMap: ) & @Freezed(maybeWhen: ) in favor of a separate:
@Freezed(map: FreezedMap(...), when: FreezedWhenOptions(...))
Breaking: Freezed now converts Lists/Maps/Sets into UnmodifiableListView/UnmodifiableMapView/UnmodifiableSetView.
This can be disabled for one class by specifying @Freezed(makeCollectionsUnmodifiable: false).
Alternatively, this can be configured inside the build.yaml file
Added parameters of @Freezed to customize the generated code.
This includes: fromJson, toJson, map, when, equal, toStringOverride, copyWith.
These parameters allow disabling code that would otherwise be generated. It also allows forcing the generation even if it would otherwise not be generated.
Feat: Add screaming snake union case type (#617) (thanks to @zbarbuto)
Fix null exceptions in some cases when using typedefs (thanks to @smiLLe)
Support analyzer 4.0.0
Fix an issue with generic Freezed classes failing to compile when using @With<Mixin<T>>() #614
Added @unfreezed as a variant to @freezed, for mutable classes
Lints are now disabled inside generated files (requires Dart 2.15)
Added support for disabling the generation of maybeMap/maybeWhen (thanks to @Lyokone)
Added support for disabling the generation of maybeMap/maybeWhen (thanks to @Lyokone)
Your coding agent can read these notes before it upgrades. Set up the MCP server →