Questions tagged [flutter-sharedpreference]

Flutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android.

Wraps platform-specific persistent storage for simple data (NSUserDefaults on iOS and macOS, SharedPreferences on Android, etc.). 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.

Visit: shared_preferences

114 questions
0
votes
1 answer

Flutter save state of an app when you exit the app (The app starts from login page after logging in the home page)

I am new to Flutter and REST API, so take it easy on me. My app is supposed to save its state according to YouTube videos that I have learnt. However, when I login and exit the app, the next time I open the app it doesn't start from a HomePage, it…
Davrick
  • 301
  • 1
  • 4
  • 13
0
votes
3 answers

shared preference displays the old value in release mode

Shared pref value in release mode shows the old value sometimes, during the my testing it stores the value and can get the new value that I stored just to make sure but after closing application and opening it again, sometimes it shows the the old…
BosS
  • 447
  • 2
  • 9
0
votes
0 answers

flutter shared preference null is returned

everyone I saved List in shared preference. Since List cannot be saved in shared preference, it is saved in json type. I referenced the post on the stackover. However, when reading the value stored in the preference, null was returned. Please…
Alex Hwang
  • 11
  • 1
0
votes
1 answer

Flutter shared_preferences not storing data

I am trying to implement the package shared_preferences in my Flutter app. I have included the package inside the pubspec.yaml file. I have created a helper class called StorageUtil to manage shared_preferences in the project. This is…
mvasco
  • 4,965
  • 7
  • 59
  • 120
0
votes
1 answer

Using Shared preferences in InitState of Widget causes Error

I want to render the value saved in key of object of SharedPreference Class in the App Bar as Text for which I have to declare the following code in the initState of the widget. initState() { // TODO: implement initState super.initState(); …
Bilal Saeed
  • 2,092
  • 8
  • 31
-1
votes
0 answers

Flutter Web Scraping

this is my code Future getWebsiteData(int i,int j) async { int bgChapterNum = i; int bgShlokaNum = j; Finalurl = getAudioUrlString(bgChapterNum, bgShlokaNum)!; print(Finalurl); final url=Uri.parse(getUrlString(bgChapterNum,…
-1
votes
1 answer

Shared Preference flutter web issue

I'm using shared_preference version 2.0.6, as per the documentation shared_preference version 0.5.6 by default supports web. as show in code 1st log works fine but the 2nd log not happening and in future builder showing NoSuchMethodError:…
vrb
  • 1
  • 1
-1
votes
1 answer

How can i retrieve data from SharedPreferences and store it in a const?

I need to get a number from SharedPreferences and store it in a constant. But i couldn't manage to do it. SharedPreferences sp = await SharedPreferences.getInstance(); const int index = sp.getInt('index')!; This code throws this error: Const…
Ercan Tomaç
  • 29
  • 1
  • 5
-2
votes
2 answers

Dart: A value of type 'String?' can't be assigned to a variable of type 'String'

There are 2 functions. One must return String other save this String in with SharedPreferences. The problem is, that by using prefs.getString() I get not a String but another object. The error called: A value of type 'String?' can't be assigned to a…
Daesslohnt
  • 13
  • 3
1 2 3 4 5 6 7
8