New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data doesn't persist in latest version, does in 2.0.0 (android) #37
Comments
@nicoroy2561 can you try to run https://github.com/lesnitsky/flutter_localstorage/tree/master/example on your device and let me know if it works? |
Tried running it, I get this: Launching lib/main.dart on Mi 9T in debug mode... /Users/Roy/.gradle/caches/transforms-1/files-1.1/support-compat-28.0.0.aar/c3442e3e27884e7630b3c2089605bd2b/res/values/values.xml:133:5-70: AAPT: error: resource android:attr/ttcIndex not found. FAILURE: Build failed with an exception.
BUILD FAILED in 30s |
I tried again with 3.0.0, data persists only while the app is open - upon restarting nothing that was set last time stays. rolling back again to earlier version. |
@nicoroy2561 I've checked out example both on android emulator and real device (Pixel 4XL) and it works fine... Could you please extract your code into small example project which demonstrates this issue? |
@nicoroy2561 fyi: I've recreated example app, check it out on your emulator/device |
same issue! is it solved? |
This has not yet been solved |
@Maclaon @dupiesdupreez I'd be happy to solve this if I would have been able to reproduce this... Could someone create a reproducible example/share a complete code example that doesn't work? |
Not sure how this is possible, the latest published version is v3.0.2 |
I'm currently testing it. After running into the same problem again, I found a solution here: The example app works on my device. Will take a look and see what might be the cause of it not working on my app |
I tried changing your app around a bit, even having it point to version 3.0.0 (and not the rep's one directly) and it works. |
@nicoroy2561 it would be great if you can provide a code snippet/demo app which demonstrates the issue |
@lesnitsky I know, and I wish I could. The problem is my app is fairly complex, so rearranging it into a "sample app" isn't feasible without a considerable amount of work. Basically what my app does is it connects via websockets (within a file called ws.dart) to my server, and logs the user in. That file imports data.dart, which contains and then checks for the saved data. |
@lesnitsky sorry, my mistake! the code snippet is very simple~
but, it will not persist anything when i restart my app! each time it looks like a new |
@lesnitsky can u take a glance at this issue? |
@Maclaon can you wrap - localStorage.setItem('filter_movies', ['1',2,3]);
+ try {
+ await localStorage.setItem('filter_movies', ['1',2,3]);
+ } catch (err) {
+ print(err);
+ } |
@lesnitsky's snippet in |
Any way to do this outside of future builder? I mean, is there any way it
can be integrated to the the storage.getItem call if called with await,
rather than having it return a null value if it takes too long to
initialize the library itself?
Seems rather akward having to create a separate method that one can call
and await upon to make sure it's been initialized, if it's as common as it
appears to be.
To be clear, I'm a big fan of getItem not being async, but if that means I
might get null even when a variable is set, is rather go with the async
version.
2020年6月1日(月) 午後5:23 sotisoti <notifications@github.com>:
… @lesnitsky <https://github.com/lesnitsky>'s snippet in
https://github.com/lesnitsky/flutter_localstorage/blob/master/example/lib/main.dart#L109-L119
definitely helped me fix the issue. Calling getItem in FutureBuilder(future:
storage.ready works now
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#37 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANGJ7B2BGOGMB3SW45U4ZZDRUPBYDANCNFSM4LP2CLSA>
.
|
localstorage initialization is asynchronous (since you have to read the contents of your storage from disk), that's why you should subscribe to |
I managed to get v3.0.0 working by awaiting on its readiness before fetching / updating data, so using a FutureBuilder or simply await should fix this. Apparently they changed something within the latest stable flutter update, as even v2.0.0 I had been using thus far wouldn't be loaded properly any longer now. |
Hi, I've been using this package but somehow with version 3.0.4 data wouldn't persist.
here's my code:
tried running on my android 10 phone, data wouldn't persist, even if I installed the app.
Tried changing my_data.dart to only my_data or anything else, wouldn't work as well. No error/exception was thrown either.
On a whim I thought I'd try to update the pubspec and set the package's version to 2.0.0, that worked. Now the data is persisting between hot reloads as it should.
The text was updated successfully, but these errors were encountered: