-
Type: Task
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
Problem
Hi, I'm trying to make an realm model that implements a plain dart class, but currently it's quite cumbersome to do so.
The reason for this is I want to decouple my model class in domain layer from the data layer
For example I have this plain dart class
class UserSession { final String userId; final String token; UserSession(this.userId, this.token); }
I'm trying to make realm class that implements this class like this
@RealmModel() abstract class _RealmUserSession implements UserSession {}
Currently the generator doesn't generate the all the fields derived from UserSession, unless I explicitly include them in the class
@RealmModel() abstract class _RealmUserSession implements UserSession { late final String userId; late final String token; }
Solution
I think it would be better if the generator can generate realm model with all the fields derived from the parent class by default
If the fields is not a RealmModel, we can override them like this
class Foo { final String id; final Bar bar; } @RealmModel() abstract class _RealmFoo implements Foo { @override Bar get bar => realmBar!; // or provide default value or throw when null late _RealmBar? realmBar; } @RealmModel() abstract class _RealmBar implements Bar {}
Alternatives
No response
How important is this improvement for you?
I would like to have it but have a workaround
Feature would mainly be used with
Local Database only