@@ -145,14 +145,10 @@ class EntityResolver extends Builder {
145145 fieldType = OBXPropertyType .StringVector ;
146146 } else if (fieldTypeDart.element.name == 'Int8List' ) {
147147 fieldType = OBXPropertyType .ByteVector ;
148- dartFieldType =
149- fieldTypeDart.element.name; // needed for code generation
148+ dartFieldType = fieldTypeDart.element.name; // for code generation
150149 } else if (fieldTypeDart.element.name == 'Uint8List' ) {
151150 fieldType = OBXPropertyType .ByteVector ;
152- // TODO check if UNSIGNED also applies to byte-vector in the core
153- flags | = OBXPropertyFlags .UNSIGNED ;
154- dartFieldType =
155- fieldTypeDart.element.name; // needed for code generation
151+ dartFieldType = fieldTypeDart.element.name; // for code generation
156152 } else {
157153 log.warning (
158154 " skipping property '${f .name }' in entity '${element .name }', as it has an unsupported type: '${fieldTypeDart }'" );
@@ -206,23 +202,8 @@ class EntityResolver extends Builder {
206202
207203 // If available use index type from annotation.
208204 if (indexAnnotation != null && ! indexAnnotation.isNull) {
209- // find out @Index(type:) value - its an enum IndexType
210- final indexTypeField = indexAnnotation.getField ('type' );
211- if (! indexTypeField.isNull) {
212- final indexTypeEnumValues = (indexTypeField.type as InterfaceType )
213- .element
214- .fields
215- .where ((f) => f.isEnumConstant)
216- .toList ();
217-
218- // Find the index of the matching enum constant.
219- for (var i = 0 ; i < indexTypeEnumValues.length; i++ ) {
220- if (indexTypeEnumValues[i].computeConstantValue () == indexTypeField) {
221- indexType = obx.IndexType .values[i];
222- break ;
223- }
224- }
225- }
205+ final enumValItem = enumValueItem (indexAnnotation.getField ('type' ));
206+ if (enumValItem != null ) indexType = obx.IndexType .values[enumValItem];
226207 }
227208
228209 // Fall back to index type based on property type.
@@ -263,25 +244,33 @@ class EntityResolver extends Builder {
263244 }
264245 }
265246
266- // find out @Property(type:) field value - its an enum PropertyType
267- int /*?*/ propertyTypeFromAnnotation ( DartObject typeField) {
268- if (typeField.isNull) return null ;
269- final enumValues = (typeField.type as InterfaceType )
270- .element
271- .fields
272- . where ((f) => f.isEnumConstant)
273- . toList ();
274-
275- // Find the index of the matching enum constant.
276- for ( var i = 0 ; i < enumValues.length; i ++ ) {
277- if (enumValues[i]. computeConstantValue () == typeField) {
278- return propertyTypeToOBXPropertyType (obx. PropertyType .values[i]);
247+ int /*?*/ enumValueItem ( DartObject typeField) {
248+ if ( ! typeField.isNull ) {
249+ final enumValues = (typeField.type as InterfaceType )
250+ .element
251+ .fields
252+ . where ((f) => f.isEnumConstant)
253+ . toList ();
254+
255+ // Find the index of the matching enum constant.
256+ for ( var i = 0 ; i < enumValues.length; i ++ ) {
257+ if ( enumValues[i]. computeConstantValue () == typeField ) {
258+ return i;
259+ }
279260 }
280261 }
281262
282263 return null ;
283264 }
284265
266+ // find out @Property(type:) field value - its an enum PropertyType
267+ int /*?*/ propertyTypeFromAnnotation (DartObject typeField) {
268+ final item = enumValueItem (typeField);
269+ return item == null
270+ ? null
271+ : propertyTypeToOBXPropertyType (obx.PropertyType .values[item]);
272+ }
273+
285274 DartType /*?*/ listItemType (DartType listType) {
286275 final typeArgs =
287276 listType is ParameterizedType ? listType.typeArguments : [];
0 commit comments