inferType method
void
inferType()
Implementation
void inferType() {
final type = nonNullableOf<V>();
final Map<Type, AbstractType> types = {
String: StringType(), // default unconstrained
int: IntType(),
double: DoubleType(),
bool: BoolType(),
DateTime: DateTimeType()
};
final Map<Type, AbstractType> nullableTypes = {
String: StringType().optional(), // default unconstrained
int: IntType().optional(),
double: DoubleType().optional(),
bool: BoolType().optional(),
DateTime: DateTimeType().optional()
};
var result = isNullable ? nullableTypes[type] : types[type];
if ( result == null)
if ( type.toString().startsWith("List<")) {
result = ListType(type);
if ( isNullable )
result = (result as dynamic).optional();
}
else {
if ( TypeDescriptor.hasType(type)) {
result = ObjectType(TypeDescriptor.forType<V>());
if ( isNullable )
result = result.optional() as AbstractType<dynamic, AbstractType>?;
}
else {
// it could be a class type or a object type that hasn't been constructed yet...
TypePatch(type: type, applyFunc: (resolvedType) => this.type = resolvedType as dynamic);
return;
}
}
this.type = result as dynamic;
}