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
copyWithmethods for immutable classes - Supports custom JSON key names via
@JsonKeyannotations - Handles basic Dart types (int, double, bool, String) and custom objects
Constructors
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