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

Future builder runs forever, if memoizer used doesnt notify to the listerners

I am trying to switch the drawer tab, according to the value stored in shared preferences using the following code. code works fine when memoizer is not used but future builder runs forever. If I use memorizer future builder still runs at least two…
user12680761
0
votes
0 answers

Is it ok to leave (use) null check errors in flutter?

Future loadFavorite() async{ SharedPreferences prefs = await SharedPreferences.getInstance(); setState((){ FavoriteButtons = (prefs.getStringList("favorite4") ?? []).map((value) => value == 'true').toList(); }); } As…
j l
  • 43
  • 4
0
votes
1 answer

flutter)I want to make a page where the user can change the font size (with local save function)

This is my code. I want to use shared_preferences in this code so that the user can choose their own font size and that font size is applied throughout the app. However, I'm stuck at the part where I use shared_preferences to save it. I tried…
eno2
  • 73
  • 11
0
votes
2 answers

Flutter: shared_preferences on Windows - Cannot create link

I am trying to install 'shared_preferences': flutter pub add shared_preferences but I got error: Oops; flutter has exited unexpectedly: "FileSystemException: Cannot create link, path…
0
votes
1 answer

I'm trying to use shared_preferences to implement "favorites" functionality in flutter

I'm trying to create a "favorites" function using shared_preferences in flutter. Use this method to store locally without a database. The page to use is globals.dart with bool variable, button.dart which is the page selection window (change button…
0
votes
1 answer

Flutter Json FormatException

In my application, i'm trying to retrieve the data from shared preferences and pass that value to the provider. How ever im getting a exception FormatException (FormatException: Unexpected character (at character 2) {token: eyJh... ^ The…
Febin Johnson
  • 277
  • 1
  • 6
  • 21
0
votes
2 answers

Flutter SharedPreferences Null check operator used on a null value

I've made a class for shared preferences. The class is as follows class StorageUtil { static StorageUtil? _storageInstance; static SharedPreferences? _preferences; static Future getInstance() async { if (_storageInstance ==…
Febin Johnson
  • 277
  • 1
  • 6
  • 21
0
votes
0 answers

how to accommodate an input into a list array in flutter

how to accommodate an input into a list array with shared preferences? I made a code like below handlesave() async { SharedPreferences ref = await SharedPreferences.getInstance(); List _arr = []; var idU = user.user.id; …
Jon
  • 109
  • 2
  • 10
0
votes
0 answers

Dart Unhandled Exception: Null check operator used on a null value,

String? videoId; String? sharedText; String? realLink; void initState() { super.initState(); WidgetsBinding.instance!.addObserver(this); intentReceiver(sharedText, videoId, realLink); } Future intentReceiver( String? _sharedText,…
0
votes
1 answer

Flutter shared preference code optimization suggestion?

I am using the shared_preferences package. https://pub.dev/packages/shared_preferences/example In my repository class, for each function, I am doing this to get the instance. SharedPreferences prefs = await SharedPreferences.getInstance(); class…
Manas
  • 3,060
  • 4
  • 27
  • 55
0
votes
1 answer

What will be the name of SharedPreference created in flutter app?

I just new in flutter and coming from android, In android we declare sharedPreference name like SharedPreferences sp = Activity.this.getSharedPreferences("USER", MODE_PRIVATE); by this in android USER.xml file was created, So, what will be the name…
tailor
  • 373
  • 4
  • 19
0
votes
0 answers

cant store user info locally with shared preferences and local storage

This code is from my local storage data file and from my testing i guess the bug is laying in the setUser method or somewhere in the next file. class LocalStorageData extends GetxController{ static const CACHED_USER_DATA = 'CACHED_USER_DATA'; …
0
votes
1 answer

How to select with sharedpreferences keys in mysql database (or json) in flutter to list favorite records?

I would like to save the sharedpreferences keys on my smartphone. The keys are table id's (autoincrements) from a table. Now i would like to show these favorite records in a new tab. How can i select with these keys in my database table? Or is it…
0
votes
1 answer

Issue in shared_preference: ^2.0.3 (latest till now 10-03-2021)

After updating flutter I have issue in one of my project. Error Log is below. Main issue is pref not save perfectly on device. some pref is save and some left. I checked it from…
0
votes
1 answer

how to fix this error ? 'flutter shared_preferences error'

E/MethodChannel#plugins.flutter.io/shared_preferences(31367): Failed to handle method call E/MethodChannel#plugins.flutter.io/shared_preferences(31367): java.util.concurrent.RejectedExecutionException: Task…