Skip to content

Insert large Json on database creation #3029

Closed Answered by fbede
fbede asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you so much for your reply @simolus3 but I have already solved the issue. I later found out that I was trying to write to the instance of the database on the "main thread" instead of the one that was created by the new isolate. To help anyone who might make the same mistake I made, this is the code snippet that was causing the error:

await database.computeWithDatabase(
   
 computation: (database) async {
   
   final assetCurrencies = loadCurrenciesFromAsset(currenciesJson);
   
   final assetIcons = loadIconsFromAsset(iconsJson);
   
   await database.batch((batch) {
   
     batch
   
       ..insertAll(currencyTable, assetCurrencies)
   
       ..insertAll(assetIconTable, assetI…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by fbede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants