constructFromMetadata static method
creates the information from the given annotations meta data
Implementation
static constructFromMetadata(List<Object> metadata) {
FieldDataType? foundType;
bool foundNullable = false;
bool foundIsPrimary = false;
for (final annotation in metadata) {
switch (annotation) {
case annotation_tags.primary:
foundIsPrimary = true;
break;
case annotation_tags.nullable:
foundNullable = true;
break;
case annotation_tags.integer:
foundType = FieldDataType.integer;
break;
case annotation_tags.float:
foundType = FieldDataType.float;
break;
case annotation_tags.text:
foundType = FieldDataType.text;
break;
case annotation_tags.boolean:
foundType = FieldDataType.boolean;
break;
case annotation_tags.date:
foundType = FieldDataType.date;
break;
}
}
if (foundType == null) throw "found no type annotations";
return FieldTypeInfo(
dataType: foundType,
isNullable: foundNullable,
isPrimaryKey: foundIsPrimary,
);
}