Dart Class Forge

A smart VS Code toolkit for generating production-ready Dart data classes. Go from properties or raw JSON to fully equipped classes — with constructors, serialization, equality, and more — in seconds.

Why Dart Class Forge?
Dart Class Forge goes beyond basic code generation. It understands your project context — detecting Flutter vs pure Dart, handling part of files, preserving your coding style, and offering 12+ targeted quick fixes so you generate exactly what you need.
Key differentiators:
- Clipboard-based JSON-to-class conversion (no temp files needed)
- Automatic ISO 8601 date detection in JSON —
DateTime fields are inferred for you
- Smart numeric array inference (
[1, 2, 3.5] correctly becomes List<double>)
factory ClassName.empty() generator for form initialization patterns
- Static example list generator with type-aware sample data
- Both
Equatable and EquatableMixin support (for classes with existing superclasses)
final class keyword support for Dart 3.0+ sealed hierarchies
- Intelligent import organization: groups dart, package, local, and relative imports separately
- Flutter project auto-detection via
pubspec.yaml
- Widget/State class awareness — never generates data class methods on UI classes
Quick Start
From Class Properties
Single class (Quick Fix):
- Write a class with properties in a
.dart file
- Place your cursor on the class name, constructor, or any field
- Press
Ctrl + . (or Cmd + . on macOS) to open quick fixes
- Pick the generation option you need
Multiple classes (Command Palette):
- Press
Ctrl + Shift + P (or Cmd + Shift + P on macOS)
- Run "Dart Class Forge: Generate from class properties"
- Select which classes to process
You can re-run the generator on existing data classes after changing properties to update all methods.
From JSON (File)
- Create an empty
.dart file and paste raw JSON into it
- Open the Command Palette and run "Dart Class Forge: Generate from JSON"
- Enter a name for the root class
- Choose whether to split nested classes into separate files
From JSON (Clipboard)
- Copy JSON to your clipboard
- Open any
.dart file
- Run "Dart Class Forge: Generate from Clipboard" from the Command Palette
- Enter a name for the root class
Smart JSON features:
- Date strings like
"2024-01-18T12:00:00Z" become DateTime fields automatically
- Mixed numeric arrays like
[1, 2, 3.5] correctly infer double
- Nested objects generate separate classes with proper references
Enum Handling
Annotate enum fields so serialization works correctly:
// enum
final Enum myEnum;
Available Quick Fixes
Place your cursor on a class and press Ctrl + . to access these actions:
| Quick Fix |
Description |
| Generate Data Class |
Full generation (constructor + all methods) |
| Generate Constructor |
Smart constructor with const inference |
| Generate copyWith |
Immutable update method |
| Generate JSON Serialization |
Both toJson and fromJson together |
| Generate toJson |
Serialization to Map |
| Generate fromJson |
Deserialization from Map |
| Generate toString |
Debug-friendly string representation |
| Generate Equality |
== operator and hashCode |
| Generate Equatable |
Equatable-based equality |
| Generate Empty Factory |
factory ClassName.empty() for forms |
| Generate Example List |
Static list of 10 sample items |
| Organize Imports |
Sort and group imports properly |
Import Organization
The import organizer groups and sorts your imports into a clean structure:
dart: core libraries
package: third-party dependencies
- Local package imports (same project)
- Relative imports
part / export statements
Each group is separated by a blank line and sorted alphabetically.
Settings
All settings use the prefix dart_class_forge. in your VS Code settings.
General
| Setting |
Description |
Default |
quick_fixes |
Enable inline quick fix actions |
true |
json.key_format |
JSON key format: variable, camelCase, snake_case |
variable |
json.separate |
Nested JSON handling: ask, separate, current_file |
ask |
json.detect_dates |
Auto-detect ISO 8601 strings as DateTime |
true |
override.manual |
Confirm before overriding each method individually |
false |
useEquatable |
Use Equatable for value equality |
false |
useEquatableMixin |
Use EquatableMixin instead of extending Equatable |
false |
final_class.enabled |
Generate with final class keyword (Dart 3.0+) |
false |
Constructor
| Setting |
Description |
Default |
constructor.enabled |
Generate constructor |
true |
constructor.default_values |
Add default values to constructor parameters |
false |
constructor.required |
Add required keyword to all named parameters |
false |
Methods
| Setting |
Description |
Default |
copyWith.enabled |
Generate copyWith method |
true |
toString.enabled |
Generate toString method |
true |
equality.enabled |
Generate == operator |
true |
hashCode.enabled |
Generate hashCode |
true |
hashCode.use_jenkins |
Use Jenkins SMI hash function |
false |
JSON Serialization
| Setting |
Description |
Default |
toJson.enabled |
Generate toJson method |
true |
fromJson.enabled |
Generate fromJson method |
true |
fromJson.default_values |
Add default values for optional params in fromJson |
false |
Additional Generators
| Setting |
Description |
Default |
emptyFactory.enabled |
Generate factory ClassName.empty() |
false |
exampleList.enabled |
Generate static example list with 10 items |
false |
License
MIT License.
Built by Taha Darwish