Skip to content
pubscout

model_generator

7.0.0, released 3 years ago by icapps.com

Automatically generate Dart models from YAML configuration files.

$ flutter pub add model_generator
Source repository

What it does

Reads a YAML file defining models, properties, enums, and types, then automatically generates corresponding Dart model classes complete with JSON serialization, equality operators, hash codes, and toString methods.

AI-written summary of version 7.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to maintain model definitions in a centralized YAML format rather than writing Dart classes manually.
  • You need automated JSON serialization, equals/hashCode, and toString generation for your data models.

Skip it when

  • You prefer writing your data classes and Freezed/JsonSerializable annotations purely in Dart code.
  • Your project does not use code generation workflows.

Strengths

  • Supports inline type definitions, generics, enums with properties, and custom converters.
  • Can look up models from a single config file or an entire directory of YAML files.

Weaknesses

  • Requires managing and writing model definitions in separate YAML files instead of native Dart code.
  • Breaking changes between major versions (such as v7.0.0) require updates to existing YAML configurations.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5

Add model_generator to your workflow and run via flutter packages run model_generator or specify custom config paths in pubspec.yaml.

model_generator:
  config_path: my_model_dir/config.yaml

Alternatives

Packages that do the same job and could replace model_generator.

Works with

Packages commonly used together with model_generator: ones it builds on, ones built on it, and its own family.