-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Shared preferences plugin - Way to clear cache or resync #22016
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
Comments
Similar to #17914 Please add the output of |
|
Have you tried checking the value and then setting a new value? @override
void initState() {
super.initState();
// checks if key is not equal to expected value
if ((prefs.getInt('key')) != expectedValue) {
// returns key of expected Value to a new value
return (prefs.getInt('key') ?? valueYouWantToChangeKeyTo);
} else {
// returns value stored in in key
return (prefs.getInt('key'));
}
} |
in background isolate, i write a data in sharepref. this problem is present because sharpref plugin use a cache when i get data. we need in sharepref plugin with a possibility to get data without cache. or a getInstance method with renew flag for créate a new instance of cache
|
This has been solved by flutter/plugins#1198, which introduced a This issue should be closed. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
It seems there is no way to reinitialize the shared preferences plugin. Its singleton instance is private, and its internal cache cannot be reset.
I'm in a situation where a flutter app and a headless background service read/write preferences with the following scenario:
If I could reset the shared preferences plugin cache when the app resume, it would solve this synchronicity issue.
The text was updated successfully, but these errors were encountered: