DartModelsGenerator class

The data class generator for dart.

Inheritance
Annotations
  • @immutable

Constructors

DartModelsGenerator({required String importPath, required String exportPath, Encoding? exportEncoding, Encoding? encoding, DartFormatter? formatter, bool? convertClassNames, bool? convertFieldNames, bool? convertInstanceNames, bool? assignFieldTypes, bool? includeNullFields, Iterable<String>? imports})
The data class generator for dart.

Properties

assignFieldTypes bool
If the unknown field types should be resolved from default values using FieldType.fromObject.
finalinherited
buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions.
no setter
convertClassNames bool?
If the class names should be converted using StringUtils.toCamelCase.
finalinherited
convertFieldNames bool?
If the field names should be converted using StringUtils.toCamelCase.
finalinherited
convertInstanceNames bool?
If the instance names should be converted using StringUtils.toCamelCase.
finalinherited
encoding Encoding
The encoding used for reading the .json and .yaml files.
finalinherited
exportEncoding Encoding
The encoding used for writing the .dart files.
finalinherited
exportPath String
The path to export data to.
finalinherited
fileMap Map<String, Object?>
The map of files that was loaded from importPath.
finalinherited
formatter → DartFormatter
The formatter used to format generated files.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
importPath String
The path to import data from.
finalinherited
imports Iterable<String>
The iterable with imports to be used in generateHeader.
final
includeNullFields bool
If the fields with null values should be added in toMap.
finalinherited
loadFiles bool
If file contents should be loaded during build into fileMap.
finalinherited
models List<ClassModel>
The map with data class names as keys and instances as values.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

build([BuildStep? buildStep]) FutureOr<void>
Generate fileMap from files under importPath.
override
generate<T extends Object?>(Iterable<ClassModel> models) String
Generate a single file with data classes from models.
generateConverter<T extends Object?>(StringBuffer buffer, ClassModel model) → void
Generate converter for the data classes file.
generateEnum<T extends Object?>(StringBuffer buffer, Iterable<ClassModel> models) → void
Generate enums for the data classes file.
generateHeader<T extends Object?>(StringBuffer buffer, Iterable<ClassModel> models) → void
Generate a header for the data classes file.
generateInstances(StringBuffer buffer, ClassModel model) → void
Generate instances for the data classes file.
generateModel<T extends Object?>(StringBuffer buffer, ClassModel model) → void
Generate models for the data classes file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renderConverter<T extends Object?>(ClassModel model, FieldModel field) String
The converter of this field in a form of String.
renderDeserialization<T extends Object?>(ClassModel model, FieldModel field, {String map = 'map'}) String
The deserialization of this field in a form of String.
renderSerialization<T extends Object?>(ClassModel model, FieldModel field) String
The serialization of this field in a form of String.
toString() String
A string representation of this object.
inherited

Operators

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