Realm.write(() { realm.add not returning anything why but it added the data to db correctly

return realm.write(() {
realm.add(Chapters(ObjectId(), 0,0,sharedWith: ,hideCategories:,
“YES”,formattedAllotedBudget.toInt(), formattedAllotedBudget.toInt(),chapterName,
ObjectId.fromHexString(chapterGroup),ObjectId.fromHexString(currency),“PENDING”,
ObjectId.fromHexString(userId),“17”,“6”,DateTime.now(),DateTime.now()));
}); not returning anything why but it added the data to db correctly

You need to add a return statement before realm.add.

i added it also but same result i do not know why it is pleas give me a reason
i did it this way
return realm.write(() {
realm.add(Chapters(ObjectId(), 0,0,sharedWith: ,hideCategories:,
“YES”,formattedAllotedBudget.toInt(), formattedAllotedBudget.toInt(),chapterName,
ObjectId.fromHexString(chapterGroup),ObjectId.fromHexString(currency),“PENDING”,
ObjectId.fromHexString(userId),“17”,“6”,DateTime.now(),DateTime.now()));
}); is this correct

As I said, you’re missing a return statement:

return realm.write(() { return realm.add(...); });

thank you for the solution

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.