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.
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.
96Compare - built_value
Provides strict immutability and code generation for complex data structures.
88Compare
Works with
Packages commonly used together with data_class_plugin: ones it builds on, ones built on it, and its own family.
- analyzerdata_class_plugin depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamldata_class_plugin depends on itA Dart library for parsing YAML documents into Dart data structures.
- globdata_class_plugin depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- dart_styledata_class_plugin depends on itProvides an API and CLI to format Dart source code automatically.
- argsdata_class_plugin depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- filedata_class_plugin depends on itPluggable, mockable file system abstraction for Dart with in-memory support.
- analyzer_plugindata_class_plugin depends on itFramework for building plugins for the Dart analysis server
- ansixBuilt on data_class_pluginProvides ANSI color, text styling, grid, and tree view tools for Dart and Flutter.