Skip to content
pubscout

data_class_plugin

1.6.1, released 6 weeks ago by ptsakoulis.com

A tool that uses Dart's Analyzer to generate data classes, unions, and enums.

WASM-ready
$ flutter pub add data_class_plugin
Source repository

What it does

It uses Dart's Analyzer and Tachyon build engine to generate boilerplate code like copyWith, toString, ==, hashCode, fromJson, and toJson for classes, unions, and enums directly through IDE code actions.

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

Use it when

  • You want fast code generation for immutable data models and union types
  • You want to avoid writing manual boilerplate code for equals, hashCode, and JSON serialization

Skip it when

  • You prefer runtime reflection or a non-codegen approach
  • You are already heavily invested in built_value or freezed

Strengths

  • Fast build times using Tachyon
  • Provides IDE code actions instead of relying purely on a watch command
  • Supports customizable naming conventions and custom JSON converters

Weaknesses

  • Requires configuring Tachyon and the analysis server
  • Has breaking changes between major versions

Setup

Kind
Pure Dart
Effort
Medium
Code generation
No
Direct dependencies
10

Requires adding dependencies, creating tachyon_config.yaml, registering the plugin in analysis_options.yaml, and restarting the analysis server.

import 'package:data_class_plugin/data_class_plugin.dart';

@DataClass()
class User {
   String get id;
   String get username;
}

Alternatives

Packages that do the same job and could replace data_class_plugin.

  • freezed

    Popular union and data class generator relying on build_runner.

  • built_value

    Provides strict immutability and code generation for complex data structures.

Works with

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