Home > Enterprise >  Objectbox Flutter Update Values Not Working
Objectbox Flutter Update Values Not Working

Time:07-06

According to the official documentation to update values you simply need to change them. https://objectbox.io/crud-flutter-database/

This is their official example: tasks[index].dateFinished = DateTime.now();

However this does not save the updated value for dateFinished. Instead, in order to update the dateFinished value I am required to use .put() to replace the task object.

Using .put is messy as it requires me to provide access to all of objectbox to the UI, rather than simply sharing a specific object with the UI.

I would like to know why their official docs say it is possible simply to change the values within the object. I would like this recommended approach to work, rather than using .put all the time.

Am I doing something wrong, or does it simply not function as described?

CodePudding user response:

Changing the property values of an object and then using put() is how to update an existing object. You don't have to share a store with all of your widgets since you can use callbacks and lift up your database logic.

I recommend reading https://docs.flutter.dev/development/data-and-backend/state-mgmt/simple.

  • Related