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
57
votes
7 answers

Flutter: remove all saved shared preferences

I want to delete all saved shared preferences when the user taps on logout. Are there any ways to do this in a single shot without deleting one by one?
Code Hunter
  • 10,075
  • 23
  • 72
  • 102
45
votes
6 answers

How to save List to SharedPreferences in Flutter?
I have a list of favorite music, which I retrieve from music when the app is opened for the first time, the app gets a favorite music list from favorite. I want to save this list to shared preferences.List favoriteMusic = new…
sumseflut
  • 628
  • 1
  • 7
  • 9
5
votes
2 answers

can't initialized Shared Pref using GetIt in flutter

I want to implement a session management system using Shared Preference in my flutter app. For Dependency injection, I use GetIt library. But when I run the app, it says 'flutter: Error while creating Session' 'The following ArgumentError was thrown…
4
votes
3 answers

How to access android Shared preferences(using java) on the flutter end (using dart)?

I have tried to many days but getting null value on flutter side. I have shared the code. Please let me know is there anything wrong? I also refer the link How to access flutter Shared preferences on the android end (using java) but it it exact…
3
votes
1 answer

Unhandled Exception: type 'Null' is not a subtype of type 'List' in type cast

Objective is to convert a String to List using map and return the value to a function call. I am using SharedPreferences to save a list of object called where in I save the data at a point and get the data when it is to be put on view. The below…
3
votes
2 answers

How to access Flutter's shared preference file?

I am pretty new to flutter and currently, I am writing an app that needs to store key-value pairs to disk and read it each time the app is open. I based on this document, using shared preference package, and it works fine. However, debugging is not…
3
votes
5 answers

How to create a bool list in shared_preferences and store values ​there

required this.favorite, I got the bool value from the previous page like this. Since I used the pageview, I want to store the value in the index like this and use it later. loadFavorite() async{ SharedPreferences prefs = await…
eno2
  • 73
  • 11
3
votes
1 answer

How to define MODE of Shared_Preferences in Flutter

In Android, we are defining Shared Preferences Mode like getSharedPreferences(String name, int mode) MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE How we can define MODE in shared_preferences flutter?
2
votes
1 answer

Flutter app losing local data when user closes the app

My app uses both shared_preferences and writing to a local json file (getting path using path_provider) for the data that it uses. I recently started testing it (starting 1/1/22) with a larger group and some people are having an issue where the data…
2
votes
3 answers

Not getting updated value from SharedPreferences

My flutter app is listening to SMS in foreground as well as background using the telephony package. While registering to receive the messages, I have used two methods (one for foreground and one for background, as required by the telephony package…
Priyshrm
  • 662
  • 8
  • 20
2
votes
0 answers

SharedPreference lost data on app Killed/Close Flutter

I am saving modal object converted into String to SharedPreference and Killing the app. But when I come back to app SharedPreference has lost the saved data. I am new to flutter. Please help. I want to save my data and kill the app and again…
Juno
  • 347
  • 2
  • 11
2
votes
0 answers

SharedPreferences: Unhandled Exception: Null check operator used on a null value

This is the whole code file when running getInstance() on SharedPreferences it throws "Null check operator used on a null value" error. but works when getInstance is called in initState import 'package:flutter/material.dart'; import…
balu k
  • 3,515
  • 2
  • 14
  • 29
1
vote
0 answers

How do I replace/ add to current data stored in Shared Preferences dynamically flutter

Screen code I am building a timesheet function on flutter where I get a list from JSON like this [ { "date": "2023-02-06 00:00:00.000", "startTime": "2023-02-06 07:00:00.000", "endTime": "2023-02-06 16:00:00.000" }, { "date":…
1
vote
2 answers

Getx Storage return null whenever app starts

I have initilized GetStorage() in main() and calling .read() in onReady dunction of GetX Controller but always get null! Future main() async { await GetStorage.init(); runApp(const App()); } class AuthenticationRepository extends…
1
vote
1 answer

Flutter: when move to new page shared_prefernce from some reason stop working

When back to BlueSettings page, initState show null on "Current value:" When use stand alone BlueSettings whithout any MaterialPageRoute, it works I want to use with MaterialPageRoute, what I do I miss? Thanks for your help here is my…
FelX3
  • 49
  • 5
1
2 3 4 5 6 7 8