TypeDefinition class

Contains information about the type of fields, arguments and return values.

Constructors

TypeDefinition({required String className, List<TypeDefinition> generics = const [], required bool nullable, String? url, DartType? dartType, bool customClass = false, SerializationDataType? serializationDataType, EnumDefinition? enumDefinition, SerializableModelDefinition? projectModelDefinition, String? recordFieldName, int? vectorDimension})
TypeDefinition.fromDartType(DartType type, {String? recordFieldName})
Creates an TypeDefinition from a given DartType. throws FromDartTypeClassNameException if the class name could not be determined.
factory
TypeDefinition.mixedUrlAndClassName({required String mixed, List<TypeDefinition> generics = const [], required bool nullable, bool customClass = false, int? vectorDimension})
Creates an TypeDefinition from mixed where the url and className is separated by ':'.
factory

Properties

asNonNullable → TypeDefinition
Get this TypeDefinition, but non nullable.
no setter
asNullable → TypeDefinition
Get this TypeDefinition, but nullable.
no setter
className → String
The class name of the type.
final
columnType → String
Get the Column extending class name representing this TypeDefinition.
no setter
customClass → bool
True if this type references a custom class.
final
dartType → DartType?
final
databaseType → String
Get the pgsql type that represents this TypeDefinition in the database.
no setter
databaseTypeEnum → String
Get the enum name of the ColumnType, representing this TypeDefinition in the database.
no setter
defaultValueType → DefaultValueAllowedType?
Returns DefaultValueAllowedType only for fields that are allowed to have defaults
no setter
enumDefinition ↔ EnumDefinition?
getter/setter pair
generics → List<TypeDefinition>
The generics the type has.
final
hashCode → int
The hash code for this object.
no setterinherited
isCollectionType → bool
no setter
isColumnSerializable → bool
no setter
isColumnStructured → bool
no setter
isEnumType → bool
no setter
isFutureType → bool
no setter
isGeographyType → bool
no setter
isIdType → bool
no setter
isJsonbSerialized → bool
no setter
isListType → bool
no setter
isMapType → bool
no setter
isModuleType → bool
no setter
isRecordType → bool
no setter
isSerializableDartType → bool
no setter
isSerializedByExtension → bool
no setter
isSerializedValue → bool
no setter
isSetType → bool
no setter
isStreamType → bool
no setter
isVectorType → bool
no setter
isVoidType → bool
no setter
moduleAlias → String?
no setter
nullable → bool
Whether this type is nullable.
final
projectModelDefinition → SerializableModelDefinition?
Populated if type is a model that is defined in the project. I.e. not a module or serverpod model.
final
recordFieldName → String?
The name of the field when used as a named record field.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serializationDataType ↔ SerializationDataType?
If set, the data type of the database JSON column this type definition should use for serialization.
getter/setter pair
url → String?
final
valueType → ValueType
converts 'className' string value to ValueType
no setter
vectorDimension → int?
Stores the dimension of Vector type (e.g., 1536 for Vector(1536)). Only populated for Vector types.
final

Methods

applyProtocolReferences(List<SerializableModelDefinition> classDefinitions) → TypeDefinition
Applies protocol references. This makes the protocol: prefix optional. First, the protocol definition is parsed, then it's check for the protocol: prefix in types. Whenever no url is set and user specified a class/enum with the same symbol name it defaults to the protocol: prefix.
asNamedRecordField(String recordFieldName) → TypeDefinition
Returns this TypeDefinition as a named record field
generateDeserialization(bool serverCode, {required GeneratorConfig config}) → List<MapEntry<Expression, Code>>
Generates the constructors for List and Map types
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reference(bool serverCode, {bool? nullable, List<String> subDirParts = const [], required GeneratorConfig config, String? typeSuffix}) → Reference
Generate a Reference from this definition.
retrieveGenericType() → TypeDefinition
Retrieves the generic from this type. Throws a FormatException if no generic is found.
toString() → String
A string representation of this object.
override

Operators

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

Static Properties

geographyClassNames → List<String>
no setter
int ↔ TypeDefinition
A convenience variable for getting a TypeDefinition of a non null int quickly.
getter/setter pair
uuid ↔ TypeDefinition
A convenience variable for getting a TypeDefinition of a non null UuidValue quickly.
getter/setter pair
vectorClassNames → List<String>
no setter

Static Methods

getRef(SerializableModelDefinition model) → String

Constants

recordTypeClassName → const String