Closed wilsleygermano closed 1 year ago
Hi @wilsleygermano,
This error appears, because you try to edit a RealmObject property outside a write
block. You have to set project.data!.first.propertyX = "80
inside your database.write
. Probably you can pass the objectToUpdate
and a function (objectToUpdate)=> objectToUpdate.propertyX = "80
to your DatabaseClient
update
method and to call this function inside database.write
block. This is just one suggestion, you may find some other way to do it.
Best regards!
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
What happened?
I'm developing a flutter app with realm as a (local-only) database. My project is based on the OOD principles, so to get the "dependency inversion principle" right, I'm using Flutter Modular. That said, when I try to update an object, I got this error:
Every other method (write, delete, read) is working well. The issue is only with the update.
If I ignore the dependency inversion principle, i.e. create an instance of my realm object on the page, then I can update the property. But I can't ignore that principle in this project.
Just in case, this is my flutter doctor output:
Repro steps
Version
Flutter 3.3.0 / Dart 2.18.0
What Realm SDK flavor are you using?
Local Database only
What type of application is this?
Flutter Application
Client OS and version
macOS 12.6
Code snippets
Stacktrace of the exception/crash you're getting
Relevant log output