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...

Комментарии • 37

  • @burakbirer5938
    @burakbirer5938 3 года назад +6

    Your tutorials are always great as you don't add unnecessary complexity. Absolutely amazing and exactly what we need. Thank you,

  • @davidsalzgeber4792
    @davidsalzgeber4792 3 года назад +3

    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!

  • @mastercoding8738
    @mastercoding8738 2 года назад +1

    I am actually a beginner and i want to know if I can use shared preference to store the state of a toggle button?

  • @TJMcCarty
    @TJMcCarty 2 года назад +1

    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!

  • @garenjohnson6554
    @garenjohnson6554 3 года назад +1

    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)

    • @BleylDev
      @BleylDev  3 года назад +2

      If you want to message me on discord I can help you out!

    • @garenjohnson6554
      @garenjohnson6554 3 года назад +2

      @@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.

  • @abolfazlrezaei2801
    @abolfazlrezaei2801 3 года назад

    Thank you , you are a life saver !

  • @milkyway9225
    @milkyway9225 2 года назад +2

    light theme - no, thanks. Ill try to find another video

  • @abdelrahmanhegazy3095
    @abdelrahmanhegazy3095 3 года назад +1

    Nice Video .. can you tell me why you removed the super.initstate ? and this will not affect on your lifecycle screen ?

  • @mianmussadiq3678
    @mianmussadiq3678 2 года назад

    i want to append all the data like first user is test second is someone we can get all previous data

  • @tubebility
    @tubebility 2 года назад +1

    Good overall, but difficult to read. You should zoom in.

  • @muniralmeslaty9602
    @muniralmeslaty9602 2 года назад

    Please!! I have an error in the setstate

  • @ahmedtiger3809
    @ahmedtiger3809 4 года назад +1

    Can we use to store images ? Locally using this package ? Sir

    • @BleylDev
      @BleylDev  4 года назад

      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

  • @k_usman
    @k_usman 3 года назад

    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!

    • @BleylDev
      @BleylDev  3 года назад

      If you jump on the discord I can help explain that for you 👍🏻 link is at footer of Bleyl.dev

    • @k_usman
      @k_usman 3 года назад

      Ohh, sure thank you.

  • @mohammedislam733
    @mohammedislam733 2 года назад

    Can I use this with provider package?

  • @nickelbackbackstage3534
    @nickelbackbackstage3534 3 года назад

    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?

    • @BleylDev
      @BleylDev  3 года назад

      That’s odd, any errors pop up in console?

    • @nickelbackbackstage3534
      @nickelbackbackstage3534 3 года назад

      @@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. :/

    • @BleylDev
      @BleylDev  3 года назад

      Odd, I’ll do some digging, but haven’t experienced that before myself

    • @nickelbackbackstage3534
      @nickelbackbackstage3534 3 года назад +1

      @@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 :))

    • @BleylDev
      @BleylDev  3 года назад

      Your good! Glad it was helpful 👍🏻

  • @tee-boss707
    @tee-boss707 2 года назад

    Please do you have a tutorial on how to make the user not to need to login again

    • @BleylDev
      @BleylDev  2 года назад

      Search for “persist authentication” to get some results that answer your question.

  • @abhishekgoswami3927
    @abhishekgoswami3927 3 года назад

    Where is your app data are store .?

  • @maurosergiorodriguesdasilv2732
    @maurosergiorodriguesdasilv2732 3 года назад

    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?

    • @BleylDev
      @BleylDev  3 года назад

      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.

  • @nijatshukurov9022
    @nijatshukurov9022 3 года назад

    Please use Dark UI pleaseeeee

  • @theplaymakerno1
    @theplaymakerno1 3 года назад

    PlayerPrefs.SetString(); ...................................