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

|
210 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

✨ Features

Generate complete data classes with:

  • ✅ Constructor with optional default values
  • ✅ copyWith method for immutable updates
  • ✅ toString method for debugging
  • ✅ toJson/fromJson methods for serialization
  • ✅ operator== and hashCode for value equality
  • ✅ Equatable integration support

🚀 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 (Beta)

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

⚠️ Beta Warning: Numbers in JSON might be interpreted as int even if they should be 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:

🔧 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.seperate How to handle nested JSON (ask, seperate, current_file) ask
override.manual Ask before overriding each method false
useEquatable Use Equatable for value equality 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 annotation 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

Made with ❤️ by Taha Darwish

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