FLUTTER ECOSYSTEM

freezed_annotation

Annotations for the freezed code-generator. This package does nothing without freezed too.

Latest version
3.1.0
30-day downloads
2.8M
Likes
553
Pub points
150

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Overview

freezed_annotation provides annotations for the freezed code generator, enabling concise and type-safe Dart classes with built-in support for immutability, copyWith methods, and JSON serialization. It works in conjunction with the freezed package to generate boilerplate code automatically. This package is essential for developers seeking clean, maintainable data models without writing repetitive code. It supports modern Dart practices such as sealed classes and union types. The annotations are used during code generation and have no runtime impact on their own.

Use cases
  • Generating immutable data classes
  • Creating sealed classes for state management
  • Automating JSON serialization
  • Simplifying state representation in UI
  • Enabling copyWith functionality
  • Defining union types
Key features
  • Immutability by default
  • Automatic copyWith methods
  • JSON serialization support
  • Sealed class generation
  • Union type definitions
  • Minimal boilerplate
Suitable for
  • Dart developers using freezed
  • Projects requiring immutable data models
  • State management with clean state classes
  • JSON-heavy applications
  • Teams prioritizing code maintainability
  • Apps targeting multiple platforms
Considerations
  • Requires the freezed package to function
  • Code generation must be enabled
  • Not suitable for runtime reflection
  • Limited to compile-time code generation
  • Dependencies must be managed carefully
  • No standalone runtime behavior
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add freezed_annotation

Categories

Source repository

Related projects