Skip to content

Need some pointers using MoorIsolate #1407

Answered by simolus3
frankvollebregt asked this question in Q&A
Discussion options

You must be logged in to vote

Are you inserting data in your database's migration? If you're using a VmDatabase.memory() you'll get a clean in-memory database for each MoorIsolate.spawn, it would not get persisted anywhere. So it's not entirely unexpected that allItems() would return an empty list after opening a fresh database. You can re-use the existing VmDatabase you were using before isolates in _backgroundConnection(). When using things like path_provider, you'll also need to call FlutterWidgetsBinding.ensureInitialized() in the background isolate to setup platform channels.

Apart from that, the code looks correct to me though.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@davidmartos96
Comment options

@simolus3
Comment options

@frankvollebregt
Comment options

@simolus3
Comment options

@frankvollebregt
Comment options

Answer selected by frankvollebregt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants