PackageTrack
Sign in Get early access

freezed

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

4.0.0 2.5M downloads/mo #234 most downloaded on pub.dev rrousselGit/freezed

What this package is like to depend on

Last release today

22 Aug 2026

Ships fairly regularly

a new release about every 2 months

Nearly every release is documented

notes for 128 of 129 stable releases

1 version withdrawn

withdrawn after publishing

7 years old

144 releases · first in 2020

10 releases in the last 12 months

see the full history below

Release timeline

144 releases · Feb 2020 to Aug 2026
2021 2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 60 of 144
  1. 4.0.0 22 Aug 2026
    Release notes
    • Fix ==/copyWith when immutable collections are enabled yet non-factory constructors are used.
    • Fix (int,) records incorrectly generated
    • Support analyzer 13.0
    • Support primary constructors
    • Breaking: No-longer support final keyword inside constructor parameter. This is due to Dart 3.13 no-longer allowing this syntax. This prevents @unfreezed from defining immutable fields.
    Open source →
  2. 4.0.0-dev.3 13 Jun 2026 pre-release
    Release notes

    fix: correct immutable collection handling in == and copyWith for non…

    Open source →
    Release notes
    • Fix ==/copyWith when immutable collections are enabled yet non-factory constructors are used.
    Open source →
  3. 4.0.0-dev.2 13 Jun 2026 pre-release
    Release notes
    • Fix (int,) records incorrectly generated
    Open source →
  4. 4.0.0-dev.1 11 Jun 2026 pre-release
    Release notes
    • Support analyzer 13.0
    • Support primary constructors
    • Breaking: No-longer support final keyword inside constructor parameter. This is due to Dart 3.13 no-longer allowing this syntax. This prevents @unfreezed from defining immutable fields.
    Open source →
  5. 3.2.6-dev.1 23 Apr 2026 pre-release
    Release notes

    freezed : 3.2.5 -> 3.2.6-dev.1

    Open source →
    Release notes

    Support analyzer 12.0

    Open source →
  6. 3.2.5 03 Feb 2026
    Release notes

    freezed : 3.2.4 -> 3.2.5

    Open source →
    Release notes

    Support analyzer 10.0

    Open source →
  7. 3.2.4 30 Dec 2025
    Release notes

    Support analyzer 9.0.0

    Open source →
  8. 3.2.3 10 Sep 2025
    Release notes

    freezed : 3.2.2 -> 3.2.3
    freezed_lint : 0.0.11 -> 0.0.12

    Open source →
    Release notes

    Broader the version range for analyzer/source_gen/build

    Open source →
  9. 3.2.2 09 Sep 2025
    Release notes

    freezed : 3.2.1 -> 3.2.2

    Open source →
    Release notes

    Bump build

    Open source →
  10. 3.2.1 09 Sep 2025
    Release notes

    Support latest analyzer/source_gen

    Open source →
  11. 3.2.0 18 Jul 2025
    Release notes
    • Use build 3.0.0-dev.
    • Use source_gen 3.0.0-dev.
    • Support Dart 3.8.0 and analyzer 7.5.9 as a minumum.
    Open source →
  12. 3.1.0 02 Jul 2025
    Release notes
    • Added when/map back
    • Stop writing // dart format width=80 to the generated freezed files.
    Open source →
  13. 3.0.6 05 Apr 2025
    Release notes

    Remove logs

    Open source →
  14. 3.0.5 05 Apr 2025
    Release notes
    • Fix ==/hashCode when using inheritance. The generated ==/hashCode now call super == other when necessary.
    • Fix an issue with Diagnosticable and toString
    • Fix ejecting union cases when more than one class is defined in a file
    • Fix a copyWith bug when a constructor parameter has no matching property
    • Fix null exception in some cases when using generic classes and copyWith
    Open source →
  15. 3.0.4 16 Mar 2025
    Release notes
    • Update docs (thanks to @lishaduck)
    • Support Dart 3.6.0 and analyzer 6.9.0 as a minimum.
    Open source →
  16. 3.0.3 02 Mar 2025
    Release notes

    Update readme (thanks to @snapsl)

    Open source →
  17. 3.0.2 27 Feb 2025
    Release notes
    • Fix various deep-copy bugs
    • Throw when using extends/with but not specifying a MyClass._() constructor
    • Throw when a Freezed class forgot to include with _$MyClass
    • "Normal" classes shouldn't require MyClass._() when they define getters/methods/...
    Open source →
  18. 3.0.1 27 Feb 2025
    Release notes

    Fix a bug with diagnosticable objects.

    Open source →
  19. 3.0.0 25 Feb 2025
    Release notes

    New: Mixed mode

    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:

    • Simple classes don't need Freezed's "weird" syntax and can stay simple
    • Unions can keep using the usual factory syntax

    This 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;
    }
    

    New: Inheritance and non-constant default values.

    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;
    }
    

    New: "Eject" union cases

    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.

    Other changes:

    • Breaking: Removed map/when and variants. These have been discouraged since Dart got pattern matching.
    • Breaking: Freezed classes should now either be abstract, sealed, or manually implements _$MyClass.
    • When formatting is disabled (default), Freezed now generates // dart format off. This prevents having to exclude generated file from formatting check in the CI.
    • It is now possible to have a private constructor for unions:
      @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;
      }
      
    Open source →
  20. 3.0.0-0.0.dev 18 May 2024 pre-release

    Nothing published for this version

  21. 2.5.8 06 Jan 2025
    Release notes

    Support analyzer 7.0.0

    Open source →
  22. 2.5.7 15 Jul 2024
    Release notes
    • freezed_annotation upgraded to 2.4.4
    Open source →
  23. 2.5.6 09 Jul 2024
    Release notes
    • Generate documentation for copyWith (thanks to @rekire)
    Open source →
  24. 2.5.5 09 Jul 2024
    Release notes
    • Stop using JsonKey(ignore: true) in favour of JsonKey(includeFromJson: false, includeToJson: false) (thanks to @lrsvmb)
    • Require json_annotation ^6.8.0
    Open source →
  25. 2.5.4 02 Jul 2024
    Release notes
    • Require Dart >=3.0.0
    • Support latest collection
    Open source →
  26. 2.5.3 14 May 2024
    Release notes
    • Support analyzer 6.5.0
    Open source →
  27. 2.5.2 11 Apr 2024
    Release notes
    • Fixed copyWith(value: null) when using nullable generics
    Open source →
  28. 2.5.1 08 Apr 2024
    Release notes
    • Fixed @freezed no-longer working inside part of files.
    Open source →
  29. 2.5.0 05 Apr 2024
    Release notes
    • Added 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.
    • Fixed an InconsistentAnalysisException
    Open source →
  30. 2.4.8 05 Apr 2024
    Release notes
    • Fixed a performance problem
    Open source →
  31. 2.4.7 04 Feb 2024
    Release notes
    • Fixed broken link in docs (thanks to @iDevOrz)
    Open source →
  32. 2.4.6 15 Dec 2023
    Release notes
    • Have the == implementation use Object as parameter instead of dynamic
    Open source →
  33. 2.4.5 10 Oct 2023
    Release notes

    Loosened analyzer version to support both ^5.13.0 and ^6.0.0 (thanks to @SunlightBro)

    Open source →
  34. 2.4.4 10 Oct 2023
    Release notes

    Do not throw on unresolved annotations.

    Open source →
  35. 2.4.3 27 Sep 2023
    Release notes
    • Fix lowercase warning on generated objects.
    Open source →
  36. 2.4.2 03 Aug 2023
    Release notes
    • Support analyzer 6.0.0
    Open source →
  37. 2.4.1 12 Jul 2023
    Release notes
    • freezed_annotation upgraded to 2.3.0
    Open source →
  38. 2.4.0 11 Jul 2023 withdrawn
    Release notes
    • Allow enabling/disabling all when/map variants at once (thanks to @gaetschwartz)
    Open source →
  39. 2.3.5 05 Jun 2023
    Release notes
    • Fix regression in analyzer 5.13.0 (thanks to @SunlightBro)
    Open source →
  40. 2.3.4 13 May 2023
    Release notes
    • Fix allow dollar ($) in recursive class names (thanks to @andreasgangso)
    • Fix deprecated warning with analyzer 5.12.0 (thanks to @SunlightBro)
    • Remove warning when marking a class as abstract
    Open source →
  41. 2.3.3 03 May 2023
    Release notes
    • Fixed an issue with the generated code when classes contains a $ in their property/constructor/class name (thanks to @medz)
    Open source →
  42. 2.3.2 07 Dec 2022
    Release notes

    Fix more issues with copyWith

    Open source →
  43. 2.3.1 06 Dec 2022
    Release notes

    Fix various issues with copyWith

    Open source →
  44. 2.3.0 30 Nov 2022
    Release notes
    • 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

    Open source →
  45. 2.2.1 26 Oct 2022
    Release notes

    Upgrade analyzer

    Open source →
  46. 2.2.0 14 Oct 2022
    Release notes
    • 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)
    Open source →
  47. 2.1.1 20 Sep 2022
    Release notes
    • Bump Analyzer to 5.0.0
    • Fix an issuee where Freezed fails to detect that the Diagnosticable API is available
    Open source →
  48. 2.1.0 15 Jul 2022
    Release notes
    • Add support for de/serializing generic Freezed classes (Thanks to @TimWhiting)
    • Fixed a StackOverflow error when defining circular exports (Thanks to @TimWhiting)
    Open source →
  49. 2.1.0+1 15 Jul 2022
    Release notes

    Improve pub score

    Open source →
  50. 2.0.5 12 Jul 2022
    Release notes

    Increase minimum analyzer version.

    Open source →
  51. 2.0.4 06 Jul 2022
    Release notes

    Fixes a bug where using @unfreezed on unions somehow still generated immutable properties.

    Open source →
  52. 2.0.3 06 May 2022
    Release notes
    • 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)
    Open source →
  53. 2.0.3+1 12 May 2022
    Release notes

    Update warning message when using abstract freezed classes

    Open source →
  54. 2.0.2 20 Apr 2022
    Release notes

    Fixed invalid generated code when defining nullable collections.

    Open source →
  55. 2.0.1 20 Apr 2022
    Release notes
    • 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
    Open source →
  56. 2.0.0 19 Apr 2022
    Release notes
    • 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

    Open source →
  57. 1.1.1 29 Dec 2021
    Release notes
    • Lints are now disabled inside generated files (requires Dart 2.15)
    • Upgraded the analyzer version to 3.0.0
    Open source →
  58. 1.1.0 11 Dec 2021
    Release notes

    Added support for disabling the generation of maybeMap/maybeWhen (thanks to @Lyokone)

    Open source →
  59. 1.0.2 05 Dec 2021
    Release notes

    Fixed a regression with the ==/hashCode implementation generated for classes with custom implementations of List/Map/... (see https://github.com/rrousselGit/freezed/issues/561)

    Open source →
  60. 1.0.2+1 09 Dec 2021
    Release notes

    Updated the README

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive