How to use SqlitePersistentStorage on Android #197
-
I am trying to use the SqlitePersistentStorage since I will have thousands of tasks to track and I think the default local_storage will be a bottleneck. I created FileDownloader in main() with SqlitePersistentStorage, but it's throwing error about "db" not being initialized. When I manually call the initialize() before passing it to FileDownloader, it complains about "db" already being initlized. I have no clue what to do. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, sorry this is causing problems. You should call If this is causing problems, can you share the code snippet you use, and also the Flutter logs around that time (with the apparent reference to the db not being initialized)? |
Beta Was this translation helpful? Give feedback.
-
I suggest separating the trackTasks call, and running it with a slight delay: The database initialization is async, but not awaited so I think what's happening here is that you call trackTasks when the DB initialization is still running. I'll look into a more elegant solution, but please try this for now |
Beta Was this translation helpful? Give feedback.
-
V8.0.0 adds a However, |
Beta Was this translation helpful? Give feedback.
I suggest separating the trackTasks call, and running it with a slight delay:
Future.delayed(const Duration(milliseconds: 50), (_) => FileDownloader().trackTasks())
The database initialization is async, but not awaited so I think what's happening here is that you call trackTasks when the DB initialization is still running. I'll look into a more elegant solution, but please try this for now