FieldSpec class

A single field parsed from a --fields spec, e.g. title:String or age:int? (the trailing ? marks the field nullable), or inferred from a JSON sample (where isModel flags fields whose type is a generated model that exposes fromJson / toJson).

Constructors

FieldSpec(String name, String type, bool nullable, {bool isModel = false})
const

Properties

ctorParam String
Constructor parameter: required this.title or this.age for nullables.
no setter
declaration String
final String title;
no setter
displayExpr String
A reasonable placeholder used when rendering a field in a generated view.
no setter
fullType String
Type including the ? suffix when nullable.
no setter
hashCode int
The hash code for this object.
no setterinherited
isModel bool
True when type (or, for a List<T>, its element T) is a generated model with fromJson / toJson constructors, so (de)serialization must recurse instead of casting.
final
listElement String
The element type of a List<...> field (defaults to dynamic).
no setter
name String
Field name in camelCase (normalized from whatever the user typed).
final
nullable bool
Whether the field is nullable (declared with a trailing ?).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
Dart type as written, e.g. String, int, List<String>, Address.
final

Methods

fromJsonExpr() String
Right-hand side that reads this field out of a JSON map.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sampleLiteral() → ({String dart, String json})
A literal sample value for this field, used in generated round-trip tests. Returns the Dart literal and its matching JSON literal (which differ for DateTime, where JSON carries an ISO-8601 string).
toJsonEntry() String
'title': title (models and DateTimes are serialized recursively).
toString() String
A string representation of this object.
inherited

Operators

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