Dart Class Generator

A toolkit providing builder-based library for dart code generation such as classes, methods, properties and constructors.

"I have used Dart to create Dart"


  • Generate classes, constructors, methods, properties with ease
  • Pre-made generation of copyWith, serialization (toMap, fromMap) and Equatable
  • Outputs everything as a simple string which you can then write to a file on your own

Attention! This does not work with Dart's build package. This is a standalone library written in Dart that builds Dart code.

Getting started

  1. Add the dependency to your pubspec.yaml file
class_generator: ^1.0.0
  1. Import the dependecy in your code file
import 'package:class_generator/class_generator.dart';


Build your first class

final name = Field('String', 'name', prefix: 'final');
final age = Field('int', 'age', prefix: 'final');
final builder = ClassBuilder('Human');
    ..addFields([name, age]);


Additional information