flutter model with both .obs and hive fields

Viewed 463

I'm kinda new to flutter. I am writing an application with Getx and Hive packages.

I would like to make my model observable by making each field reactive. I prefer this approach rather than making the entire class observable in the controller; by doing that it's the model itself that raises the changes and this seems to me more similar to a standard mvvm approach (you can correct me if I am wrong).

I would like also to mark my model fields with @HiveField.

Now, the problem is that I cannot mark Rx fields and I am forced to write two different fields, the Rx one and the Hive one. Something like that:

  @HiveField(1)
  int _fieldDb;

  RxInt fieldRx;

  GbTrait(int value) :
    _fieldDb = value,
    fieldRx = value.obs;

By doing that I need to update the two values all the time...Is there a better way? Thanks a lot for the help.

0 Answers
Related