- The generated
copyWith
is now annotated by@useResult
(thanks to @miDeb) - Improved performance of
copyWith
(thanks to @miDeb) - Improved type inference when using
mapOrNull
/whenOrNull
(thanks to @DevNico) - Re-introduced
@With.fromString
and@Implements.fromString
to allow unions to implement generic types. (thanks to @rorystephenson) - fixes @Default for Strings containing (, [ or { (thanks to @hugobrancowb)
- fix Freezed incorrectly comparing primitives using
DeepCollectionEquality
(thanks to @knaeckeKami) - fix image links (thanks to @SunlightBro)
- Bump Analyzer to 5.0.0
- Fix an issuee where Freezed fails to detect that the
Diagnosticable
API is available
Improve pub score
- Add support for de/serializing generic Freezed classes (Thanks to @TimWhiting)
- Fixed a StackOverflow error when defining circular
export
s (Thanks to @TimWhiting)
Increase minimum analyzer version.
Fixes a bug where using @unfreezed
on unions somehow still generated immutable properties.
Update warning message when using abstract freezed classes
– fix: performance regression with ==/hashCode/copyWith due to immutable collections (#653) – fix: build.yaml decoding crash
- fix: remove annotations on internal properties related to immutable collections (#659)
Fixed invalid generated code when defining nullable collections.
- Fixed a bug where the generated when/map methods were potentially invalid when using default values
- Fixed a bug where when/map methods were generated even when not necessary
-
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 thebuild.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)
- Upgraded the analyzer version to 3.0.0
Added support for disabling the generation of maybeMap
/maybeWhen
(thanks to @Lyokone)
Updated the README
Fixed a regression with the ==/hashCode implementation generated for
classes with custom implementations of List
/Map
/... (see #561)
Fixed an issue where some build.yaml
options were not properly considered.
This includes changing where the generated files should be placed. (Thanks to @sperochon)
Freezed is now stable
This release also:
- reverted an involuntary change of how union types were de/serialized, breaking existing code.
- fixed an issue with generic typedefs (thanks to @SunlightBro #552)
- fixed a potential null exception
- Fixed a bug where the generated code for serializable unions with a base class was invalid
- The union key is no longer passed
json_serializable
when deserializing avoid the case of being anunrecognized_key
in some cases. - Updated dependencies
- Increased minimum Dart SDK required to 2.14.0
- Fixed an issue where classes with a $ in their name could cause Freezed to fail (Thanks to @comigor #542)
- When using typedefs, the generated code now tries to use the typedef too if possible, instead of the aliased type (Thanks to @Norbert515 #536).
- Added support for custom ==/hashCode implementation (Thanks to @casvanluijtelaa #526)
- When writing a custom
toJson
function, it will now always take precedence over the default implementation generated by Freezed.
Fixed the generated hashCode
not compiling for objects with a large number
of properties. (#531)
-
Breaking Changed the syntax for
@With
and@Implements
to use a generic annotation. Before:@With(MyClass) @With.fromString('Generic<int>')
After:
@With<MyClass>() @With<Generic<int>>()
-
Fixed an issue with fromJson tear-offs not allowing
Object?
as map value. (#520) -
Optimized the generated implementation of
hashCode
and==
-
Fixed an issue when
MyClass<Object>()
andMyClass<int>()
could be considered equal -
Require Dart SDK >=2.14.0.
- fixed a bug when using alias imports, potentially using the prefix on every variables.
- When
@Freezed(fallback: '...')
is specified and usingfromJson
, now support cases where the JSON does not contain the "key".
- Now supports types coming from
import '...' as alias;
- generated .freezed.dart are now excluded from code coverage reports.
- if
toString
is overridden, Freezed no-longer appliesDiagnosticable
which would break thetoString
(fixes #221) - Add
union.whenOrNull
andunion.mapOrNull
, similar tomaybeWhen
andmaybeMap
but instead of anorElse
they returnnull
.
- Upgraded to support json_serializable 5.0.0
fromJson
now throwsCheckedFromJsonException
if it fails to deserialize an object.- fixed an issue where optional dynamic keys were not allowed.
- Added the ability to specify a fallback constructor when deserializing unions (thanks to @Brazol)
Upgrade dependencies
Fixed examples in the README
- Fixed issues with recursive Freezed classes that could cause the parameter type to be inferred as
dynamic
(see #399) - Updated
build
and other similar dependencies to latest
-
Added the ability to customise the JSON value of a union. See https://github.com/rrousselGit/freezed#fromjson---classes-with-multiple-constructors for more information (Thanks to @ookami-kb)
-
Fix an issue where Freezed would not generate code properly if
freezed_annotation
was indirectly imported (by importing a library that exportsfreezed_annotation
) (Thanks to @ookami-kb)
- Fix
@Assert
no-longer working - Fixed an issue where a
factory
using the=>
syntax (so not managed by Freezed) with default values could break code-generation.
- fix
sort_unnamed_constructors_first
andcast_nullable_to_non_nullable
in the generated code (Thanks to @gaetschwartz #372)
-
Stable null-safety release
-
Upgraded
analyzer
to support latest versions -
Freezed classes no-longer need to be abstract.
Before:@freezed abstract class Example with _$Example { factory Example(int value) = _Example; }
after:
@freezed class Example with _$Example { factory Example(int value) = _Example; }
This leads to better error messages when a Freezed class uses interfaces/mixins but the class is missing a specific property.
-
It is now allowed to add unimplemented getter to Freezed classes. This can be useful to guarantee that union-types all have a common property:
@freezed class Union with _$Union { const factory Union.left(int value) = _Left; const factory Union.right(int value) = _Left; @override int get value; // adding this forces all union cases to possess a `value` property }
-
Excluded getters and late variables from the generated
toString
as they could potentially cause a StackOverflow -
Fixed a bug causing properties with annotations to generate the annotations before the `required keyword, leading to a compilation error (see #351).
- Upgraded
analyzer
to support latest versions
-
Freezed classes no-longer need to be abstract.
Before:@freezed abstract class Example with _$Example { factory Example(int value) = _Example; }
after:
@freezed class Example with _$Example { factory Example(int value) = _Example; }
This leads to better error messages when a Freezed class uses interfaces/mixins but the class is missing a specific property.
-
It is now allowed to add unimplemented getter to Freezed classes. This can be useful to guarantee that union-types all have a common property:
@freezed class Union with _$Union { const factory Union.left(int value) = _Left; const factory Union.right(int value) = _Left; @override int get value; // adding this forces all union cases to possess a `value` property }
- Excluded getters and late variables from the generated
toString
as they could potentially cause a StackOverflow
- Fixed a bug causing properties with annotations to generate the annotations before the `required keyword, leading to a compilation error (see #351).
Migrated to null safety
- fixed a bug where
///
above a constructor could cause the generation to stop working (see also #326)
- Fix Freezed generating code from constructors that do not rely on Freezed (#323)
- Fixes a bug where comments on named parameters could break generation (#317)
- fixed a bug that caused the code-generation to never complete (#312)
- Renamed
Result
in generated code toTResult
to avoid naming conflicts - Fixes
InconsistentAnalysisException
sometimes being thrown (#294)
- Renamed
Result
in generated code toTResult
to avoid naming conflicts - Fixes
InconsistentAnalysisException
sometimes being thrown (#294)
- Upgrade the dependencies (analyzer, build_runner)
- fixed a bug where a custom
fromJson
constructor still generated thefromJson
constructor with json_serializable (see also #280) - fixed a generation issue when
unionKey
contains special characters (see also #274)
- Removed dependency on
_fe_analyzer_shared
-
Added
/// @nodoc
on objects generated by Freezed that starts with$
to not pollute dartdoc. -
Added support for documenting properties, by documenting the constructor parameters:
@freezed abstract class Example with _$Example { const factory Example( /// Some documentation String parameter, ) = Person; }
-
Added
Assert
decorator to generateassert(...)
statements on Freezed classes:@freezed abstract class Person with _$Person { @Assert('name.trim().isNotEmpty', 'name cannot be empty') @Assert('age >= 0') factory Person({ String name, int age, }) = _Person; }
-
Now generates a constructor tear-off for
fromJson
too:@freezed abstract class Person with _$Person { factory Person({ String name, int age}) = _Person; factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json); } List<Map<String, dynamic>> list; List<MyClass> persons = list.map($Person.fromJson).toList();
-
Added a way to customize the de/serialization of union types using the
@Freezed(unionKey: 'my-key')
decorator.See also https://github.com/rrousselGit/freezed#fromjson---classes-with-multiple-constructors
-
Fixed a bug where deep-copy did not work properly for recursive classes (#213)
-
Fixed a situation where
@late
properties could trigger aRangeError
(#219)
- Fixed a bug in which case Freezed generated an invalid
copyWith
implementation
- No-longer generate
when
/... for private constructors.
- Fixed a bug where the generated class incorrectly used
Diagnosticable
event ifpackage:flutter/foundation
wasn't imported. (Thanks to @avbk)
- Generate
when
/map
/... even for classes with a single constructors (thanks @andrzejchm)
- Further improve the parsing of recursive freezed class to avoid
dynamic
s
-
Added
@With
and@Implements
decorators to allow only a specific constructor of a union type to implement an interface:@freezed abstract class Example with _$Example { const factory Example.person(String name, int age) = Person; @Implements(GeographicArea) const factory Example.city(String name, int population) = City; }
Thanks to @long1eu
-
Fixed a bug where a recursive freezed class may generate a property as dynamic (thanks to @maks)
-
Improved the readme (Thanks to @scopendo and @Matsue)
- Fixes a bug where code-generation could end-up in a Stack Overflow if a class depends on itself
- Fix code-generation issue for deep-copy of generic objects (#128)
- Fixes a bug where classes with both getters and consts constructors caused an exception. (#142)
- do not create
@required
annotation for positional arguments onwhen
/map
functions (thanks to @hpoul) - Fix == returning false for classes with "other" prop (thanks to @mhmdanas)
Fixes classes with getters and a private MyClass._()
constructor not properly generating.
Fixed Freezed trying to generate code for factory constructors with a complex body.
- Fixes Freezed trying to generate code for files that don't use it
- Fixes a bug where deep copy did not compile if the class definitions were spread on multiple files.
- Fixed a stack-overflow during generation on recursive classes
- Fixed invalid generated code for classes with a concrete constructor + using Diagnosticable
- Consider optional parameters with a default value as non-nullable
- Add deep-copy support
- Allow the class to define methods/getters
- Do not override
toString
if the user-defined class already overridestoString
Fixes parsing of recursive classes
Support enum and static const default values
Support class-level decorators (see #50)
Generated file now ignores invalid_override_different_default_values_named
Now also generate constructor tear-off.
Fixes @Default
generating invalid code if the default value explicitly used const
.
Fix null/bool default value support
Fixes a bug where @Default
only worked with strings/numbers/functions/types.
Add support for default values
- Make
freezed
ignoreuse_function_type_syntax_for_parameters
warnings (see #57)
- Fixes an issue with inconsistent
hashCode
when using collections - Fixes a parsing bug with complex concrete factory constructors.
Fixed a bug where @late
could incorrectly parse the getter
Add support for cached getters using @late
.
- Document
@nullable
- fix a bug where static members where not allows (thanks @knaeckeKami)
The generated == now works with collections too.
If a class created has a List/Map/Set/Iterable, then the == will deeply compare these instead of comparing their reference.
Automatically generate assert(property != null)
on both constructors and copyWith
methods.
This also adds a @nullable
decorator to disable this assertion.
Now use a custom @freezed
annotation instead of @immutable
.
Fixed a bug where generic json deserialization didn't apply generic parameters (#32)
Make the generated interface a mixin to fix prefer_mixin
lints (#28)
Fixes a bug where constructors with generic parameters caused the parsing of the redirected constructor to fail. (#25)
Fixes a bug where the code would not compile if a property had the same name as a named constructor.
Fixes a bug where classes with a single constructor + fromJson did not generate properties/copyWith.
Transfer all parameters decorators to the generated properties.
- Fixed a bug where
map
/maybeMap
on generic classes didn't pass the generic parameters.
- Fix README's index
- Don't generate anything for factory constructors with a body. (#9)
-
fromJson
/toJson
no longer require/add aruntimeType
key for classes with a single constructor. (#7) -
don't generate anything for classes that add
@freezed
but define real properties (#5)
Upgrade min range of analyzer
dependency
Add support for json_serializable
Implicitly generate debugFillProperties
if the necessary classes are imported.
Add generic support
Initial release