Local Storage in Flutter with Shared Preferences
HTML-код
- Опубликовано: 9 сен 2024
- This tutorial shows how to use the shared_preferences package to store variables locally in your flutter app.
Package Link: pub.dev/packag...
Code: bitbucket.org/...
Medium Article: / how-to-use-local-stora...
Your tutorials are always great as you don't add unnecessary complexity. Absolutely amazing and exactly what we need. Thank you,
Thanks Burak!
Thank you so much! I worked at an app for 2 weeks with sql and other stuff. And this is so easy to impement in 2 minutes. Thank you!
I am actually a beginner and i want to know if I can use shared preference to store the state of a toggle button?
I noticed this text in the shared_preferences documentation: "Data may be persisted to disk asynchronously, and there is no guarantee that writes will be persisted to disk after returning, so this plugin must not be used for storing critical data."
Does that mean that the local storage won't be saved if the user kills the app and then returns back to the app? Or will the saved local variables still be there after the user kills an app and opens back up the app?
Thanks!
I am getting this error when using the plugin. Any idea why its happening?
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
If you want to message me on discord I can help you out!
@@BleylDev Thanks so much but i actually fixed the issue already. I just googled a whole bunch of solutions and eventually one them worked. Thanks for replying tho thats really considerate of you.
Thank you , you are a life saver !
No problem!
light theme - no, thanks. Ill try to find another video
Thanks, bye!
Nice Video .. can you tell me why you removed the super.initstate ? and this will not affect on your lifecycle screen ?
i want to append all the data like first user is test second is someone we can get all previous data
Good overall, but difficult to read. You should zoom in.
Please!! I have an error in the setstate
Can we use to store images ? Locally using this package ? Sir
Not using local storage no, but you can cache the image and then recall it. There is a good thread of answers on this stack overflow link: stackoverflow.com/questions/49455079/flutter-save-a-network-image-to-local-directory
How to do it when the data is JSON from API/Local.
Is it possible to make a "favorite button" and then save it to another page.
Could you explain it to me? Thanks man!
If you jump on the discord I can help explain that for you 👍🏻 link is at footer of Bleyl.dev
Ohh, sure thank you.
Can I use this with provider package?
I really like that vid, but i have this one thing that it works on the virtual machine but on the real device it is empty first (like String displayname = '') and after another load in the app it syncs the prefs. Do you any clue why?
That’s odd, any errors pop up in console?
@@BleylDev I forgot to say that it works on real device in debug mode. If i use the released version on the phone and close the app than it has this problem.. So if i am in debug mode there are no errors. :/
Odd, I’ll do some digging, but haven’t experienced that before myself
@@BleylDev maybe you havent because i'm retard *facepalm* i missed out the setState in the get method... so it worked in debug (no clue why but did) but obviously couldn't update on reload.. Sorry for that.. But thank you anyway and again great work on that vid :))
Your good! Glad it was helpful 👍🏻
Please do you have a tutorial on how to make the user not to need to login again
Search for “persist authentication” to get some results that answer your question.
Where is your app data are store .?
Tnks for the video, how to get all data from an UserModel using Shared Preference or GetStorage? u show us how to get user name, but how about if i want to get more info about user like UserModel with more infos?
The reason I only show how to get simple variables is because local storage isn't intended to store large amounts of data. It's meant to store small amounts of data. I'm trying my best not to promote any bad implementation habits. There are ways to store a model object by stringifying the class and parsing back into the object, but it's not advised.
Please use Dark UI pleaseeeee
PlayerPrefs.SetString(); ...................................