🎯 Dart Data Class Generator
Create Dart data classes quickly without writing boilerplate or running code generation.

✨ Features
Generate complete data classes with:
- ✅ Constructor with optional default values and smart
const inference
- ✅ copyWith method for immutable updates
- ✅ toString method for debugging
- ✅ toJson/fromJson methods for serialization
- ✅ operator== and hashCode for value equality
- ✅ Equatable integration support
- ✅ Final class keyword support (Dart 3.0+)
- ✅ Empty factory constructor for form initialization
- ✅ Example list generator with sample data
🚀 Getting Started
📝 Generate from Class Properties

⚡ Quick Fix (Single Class)
- 📄 Create a class with properties
- 🎯 Place cursor on class name, constructor, or field
- ⌨️ Press
Ctrl + . (or Cmd + . on macOS)
- ✨ Select desired generation option
🔧 Command (Multiple Classes)
- ⌨️ Press
Ctrl + P (or Cmd + P on macOS)
- 🔍 Search for "Dart Data Class Generator: Generate from class properties"
- ✅ Select classes to generate when prompted
💡 Tip: You can run the generator on existing data classes to update them after property changes.
🔄 Generate from JSON

- 📄 Create an empty Dart file
- 📋 Paste raw JSON into the file
- ⌨️ Press
Ctrl + P (or Cmd + P on macOS)
- 🔍 Search for "Dart Data Class Generator: Generate from JSON"
- ✏️ Enter name for the root class
- 📂 Choose whether to separate nested classes into multiple files
📋 Generate from Clipboard (New!)
- 📋 Copy JSON to your clipboard
- 📄 Open a Dart file
- ⌨️ Press
Ctrl + P (or Cmd + P on macOS)
- 🔍 Search for "Dart Data Class Generator: Generate from Clipboard"
- ✏️ Enter name for the root class
✨ Smart Features:
- Date Detection: ISO 8601 date strings are automatically converted to
DateTime
- Array Type Inference: Mixed arrays like
[1, 2, 3.5] correctly infer double
🏷️ Working with Enums
To ensure enums are correctly serialized, annotate them:
// enum
final Enum myEnum;
🎁 Additional Features
The extension includes some additional quick fixes that might be useful to you:
📦 Import Refactoring
Sort imports alphabetically and bring them into the correct format easily.
⚙️ Settings
Customize the generator to only generate the functions you want in your settings file.
💡 Note: All settings are prefixed with dart_data_class_generator.
🔧 General Settings
| Setting |
Description |
Default |
quick_fixes |
Enable quick fixes for data class generation |
true |
json.key_format |
Format for JSON keys (variable, camelCase, snake_case) |
variable |
json.separate |
How to handle nested JSON (ask, separate, current_file) |
ask |
json.detect_dates |
Auto-detect ISO 8601 date strings as DateTime |
true |
override.manual |
Ask before overriding each method |
false |
useEquatable |
Use Equatable for value equality |
false |
useEquatableMixin |
Use EquatableMixin instead of extending Equatable |
false |
final_class.enabled |
Generate classes with final class keyword |
false |
🏗️ Constructor Settings
| Setting |
Description |
Default |
constructor.enabled |
Generate constructor |
true |
constructor.default_values |
Add default values to constructor |
false |
constructor.required |
Add required keyword to parameters |
false |
🔄 Method Generation Settings
| Setting |
Description |
Default |
copyWith.enabled |
Generate copyWith method |
true |
toString.enabled |
Generate toString method |
true |
equality.enabled |
Generate == operator |
true |
hashCode.enabled |
Generate hashCode method |
true |
hashCode.use_jenkins |
Use Jenkins SMI hash function |
false |
📦 JSON Serialization Settings
| Setting |
Description |
Default |
toJson.enabled |
Generate toJson method |
true |
fromJson.enabled |
Generate fromJson method |
true |
fromJson.default_values |
Add default values in fromJson |
false |
🆕 Additional Generators
| Setting |
Description |
Default |
emptyFactory.enabled |
Generate factory ClassName.empty() for form init |
false |
exampleList.enabled |
Generate static example list with 10 sample items |
false |
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
| |