Skip to content
pubscout

freezed_annotation

3.1.0, released a year ago by dash-overflow.net

Annotations for the freezed code-generator.

WASM-readyQuiet but busy
$ flutter pub add freezed_annotation
Source repository

What it does

Provides annotations used by the freezed code-generator package to create immutable data classes and union types. This package does nothing without freezed.

AI-written summary of version 3.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using the freezed code-generator for immutable models
  • You need annotations like @freezed, @unfreezed, @With, or @Implements

Skip it when

  • You are not using code generation or freezed
  • You need the full freezed generator functionality rather than just annotations

Strengths

  • Lightweight package providing only the necessary annotations for freezed
  • Clear separation between annotations and the code generation logic

Weaknesses

  • Does nothing without the freezed package

Setup

Kind
Pure Dart
Effort
Low
Code generation
Yes (build_runner)
Direct dependencies
3

Add to dependencies alongside freezed and build_runner in dev_dependencies.

import 'package:freezed_annotation/freezed_annotation.dart';

part 'example.freezed.dart';

@freezed
class Example with _$Example {
  const factory Example({required String name}) = _Example;
}

Alternatives

Packages that do the same job and could replace freezed_annotation.

  • built_value

    Alternative approach to creating immutable value classes in Dart via code generation.

  • json_serializable

    Alternative code generator focused specifically on JSON serialization rather than full union types and immutability patterns.

Works with

Packages commonly used together with freezed_annotation: ones it builds on, ones built on it, and its own family.