I am trying to optimize the code definition/implementation of a Custom Type on an Objectbox Entity using Flutter and Dart.
To declare a custom type in an entity I proceed in this way.
@Entity()
class Car {
/// ObjectBox 64-bit integer ID property, mandatory.
/// Add `@Id()` annotation if its name isn't "id" (case insensitive).
int id = 0;
@Transient()
CarTypeEnum carType =
CarTypeEnum.sportive;
int get dbCarType => carType.managedIndex;
set dbCarType(int managedIndex) {
carType = CarTypeEnumExtension.from(managedIndex);
}
}
My problem is that I have a lot of custom fields and the code becomes very hard to maintain and read.
It's possible create a class using Objecbox attribute (like @Transient) in a subclass to factorise the previous code ?
@Entity()
class Car {
/// ObjectBox 64-bit integer ID property, mandatory.
/// Add `@Id()` annotation if its name isn't "id" (case insensitive).
int id = 0;
CustomType<CarType> carType = CustomType<CarType>(CarTypeEnum.semicolon);
}
I search how implement CustomType class