model_generator
7.0.0, released 3 years ago by icapps.com
Automatically generate Dart models from YAML configuration files.
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.yamlAlternatives
Packages that do the same job and could replace model_generator.
- protobuf
Provides runtime support for Dart protocol buffer messages generated by protoc_plugin.
84Compare - data_class_plugin
A tool that uses Dart's Analyzer to generate data classes, unions, and enums.
71Compare - pubspec_extract
Extracts Dart pubspec.yaml file and generates pubspec.dart at build time
75Compare - flutter_secure_dotenv_generator
A development dependency to generate secure dotenv file for flutter_secure_dotenv package.
50Compare
Works with
Packages commonly used together with model_generator: ones it builds on, ones built on it, and its own family.
- yamlmodel_generator depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semvermodel_generator depends on itVersions and version constraints implementing pub's versioning policy.
- argsmodel_generator depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- build_runnerUsed togetherA build system for Dart code generation and modular compilation.