JsonToDartGenerator class

A utility class that generates Dart model classes from JSON data.

This class provides functionality to convert JSON data into strongly-typed Dart classes with proper serialization/deserialization support using json_annotation package.

Features:

  • Supports nested objects and arrays
  • Handles both camelCase and snake_case property names
  • Generates copyWith methods for immutable classes
  • Supports custom JSON key names via @JsonKey annotations
  • Handles basic Dart types (int, double, bool, String) and custom objects

Constructors

JsonToDartGenerator()

Properties

generatedClasses Map<String, String>
Cache of generated class definitions to avoid duplicates
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

generate(String className, dynamic json, {bool useCamelCase = false, bool useNullableCopyWith = false}) String
Generates a Dart class from JSON data.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited