Hello, I have a flutter project where I want to update an object property but I get this error:
Error: RealmException: Trying to modify database while in read transaction. Error code: 2005.
I tried all the documentation but still cannot solve the problem. Anyone can help me to solve it?
Still cannot solve the problem.
Once I read two types of objects into list, the exception raises.
But if I read only one type of object from db, there will be no exception with the same update code.
Once I used realm with multiple schemas, this exception raises. Even set a single property. I’m already wrap my code in write or writeAsync method but the error keep saying I’m trying to modify property in read transaction. Need help.
Because you only assigning _realm after the future resolves, there’s a brief window where db.realm is called twice and _realm is still null. That causes two different realm instances to get opened - then only one will start a write transaction, while the other will not. There’s no reason for _initDB to be a future, so if you convert it to a regular synchronous function, things work as expected.