Closed gorebang closed 4 years ago
@gorebang hot restart works for me on all platforms
Same problem here, solved adding a setState() before retrieving the first time an element from the database (xxx.getItem('')). Happens when you call getItem before finish rendering the app the first time in my case.....
could you please make sure you wait for the localstorage to be initialized
storage.getItem('item'); // null if not yet initialized
await storage.ready;
storage.getItem('item'); // should return data
Seems like https://github.com/lesnitsky/flutter_localstorage/issues/49#issuecomment-676146168 is the reason
Unlike Shared_Prefs, when an app using localstorage is hot restarted or the app is closed on the device and restarted, data isn't persisted.
This can be seen by running the example solution, adding some todo items then performing a hot restart (SHIFT R)... the items won't be persisted.
Perhaps I misunderstood the purpose of the package; I was hoping to use it to persist JSON blobs on the device to be retrieved over a longer period of time.