objectbox-dart
objectbox-dart copied to clipboard
@Property Annotation for getter/setter properties
Currently, the @Property Annotation is only available for fields, that are defined as such in the @Entity.
Describe the solution you'd like
It would be nice to be able to add the @Property Annotation also to a getter (assuming a matching setter exists). This would just have the same effect on the property defined by the getter / setter pair as if it would have, would the annotation be attached to an equivalent field.
Thanks! It's odd that this doesn't work already. Also @Transient
on a getter does not appear to get recognized.
Edit: an internal issue for this exists.
Same for @Index
, reported originally in #528.
Also freezed classes with non-required properties are affected by this, see #565.
Annotating getters will be possible with the next release.
You will be able to do something like this:
@Property(type: PropertyType.date)
@Index()
DateTime get date => TODO;
set date(DateTime value) => TODO;
@Transient()
int get computedValue => TODO;
set computedValue(int value) => TODO;