Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Dart Class GeneratorNew to Visual Studio Code? Get it now.
Dart Class Generator

Dart Class Generator

Taha Darwish

|
246 installs
| (0) | Free
Create dart data classes easily, fast and without writing boilerplate or running code generation.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🎯 Dart Data Class Generator

Create Dart data classes quickly without writing boilerplate or running code generation.

VS Code GitHub

✨ 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

Class properties demo

⚡ Quick Fix (Single Class)

  1. 📄 Create a class with properties
  2. 🎯 Place cursor on class name, constructor, or field
  3. ⌨️ Press Ctrl + . (or Cmd + . on macOS)
  4. ✨ Select desired generation option

🔧 Command (Multiple Classes)

  1. ⌨️ Press Ctrl + P (or Cmd + P on macOS)
  2. 🔍 Search for "Dart Data Class Generator: Generate from class properties"
  3. ✅ 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

JSON demo

  1. 📄 Create an empty Dart file
  2. 📋 Paste raw JSON into the file
  3. ⌨️ Press Ctrl + P (or Cmd + P on macOS)
  4. 🔍 Search for "Dart Data Class Generator: Generate from JSON"
  5. ✏️ Enter name for the root class
  6. 📂 Choose whether to separate nested classes into multiple files

📋 Generate from Clipboard (New!)

  1. 📋 Copy JSON to your clipboard
  2. 📄 Open a Dart file
  3. ⌨️ Press Ctrl + P (or Cmd + P on macOS)
  4. 🔍 Search for "Dart Data Class Generator: Generate from Clipboard"
  5. ✏️ 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.


Made with ❤️ by Taha Darwish

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft