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

The argument type 'Future' can't be assigned to the parameter type 'SharedPreferences'

I want to access the shared preferences at the application startup and want to use this same object across the entire app by passing it to the classes. I am getting the following error: The argument type 'Future' can't be assigned to the parameter…
Stack Overflow
  • 1
  • 5
  • 23
  • 51
0
votes
1 answer

getting future string and saving state in flutter

I am trying to get the string value of a future, and saving state in flutter. user chooses the endTime and it should display on the UI untill it ends. however, I am getting the following error: type 'String' is not a subtype of type 'Future'…
HaKim
  • 277
  • 2
  • 12
0
votes
1 answer

MIgrating to bloc >= 7.2.0 with multiple enevts and shared preferences

I am working on a login page that was created with the pre >=7.2.0 bloc version and I am having issues migrating this AuthBloc because it has multiple events and shared preferences within. class AuthBloc extends Bloc { …
0
votes
1 answer

How to initialize CameraController with SharedPreferences?

First I have initialized my camera controller (camera: ^0.9.4+11) like this and it works: class TakePictureScreen extends StatefulWidget { final CameraDescription camera; const TakePictureScreen({required Key key, required this.camera}) :…
Cold_Class
  • 3,214
  • 4
  • 39
  • 82
0
votes
2 answers

Flutter & Shared Preferences: How do i save and read back a List using setStringList? Also, how do i remove a specific object from the List?
class Restaurant { Restaurant({ required this.name, required this.description, required this.address, required this.imageUrl, }); Restaurant.fromJson(Map json) : this( name: json['name']! as…
peakystewie
  • 141
  • 2
  • 17
0
votes
2 answers

How to keep user logged in while using Phone Authentication in Flutter

I have the following code and I need to keep users logged when they reopen the app. I have a flutter phone authentication service from firebase. The given is function to verify google phone authentication. There is a button when pressed 2 functions…
0
votes
0 answers

how to update data from your provider store to your shared preferences in flutter

I want to update my Shared preference so that each time I update my Provider the updated List automatically gets stored in my shared preference. Here is my code. class AlarmState extends ChangeNotifier { var hour = 0; var min = 0; Set
0
votes
2 answers

Flutter - Rendering cookies dialog conditionally

I am a beginner in Flutter & Dart language and trying to figure out how to render cookie settings dialog(popup) conditionally(based on user preference) on page load. I already found some 3rd party package (sharedpreferences) to store key-value pair…
0
votes
2 answers

Shared Preference GetInstance() _TypeError (type '() => Null' is not a subtype of type '(dynamic) => dynamic' of 'f')

Flutter Version : I am getting an exception in line SharedPreferences prefs = await SharedPreferences.getInstance();. Exception has occurred. _TypeError (type '() => Null' is not a subtype of type '(dynamic) => dynamic' of 'f') The same code is…
Dark Sorrow
  • 1,681
  • 14
  • 37
0
votes
1 answer

How to store List in Flutter using sharedPreferences?
I want to save list of PlatformFile, with the help of file_picker library and store them using sharedpreferences and then load them back. list -> List
user17863390
0
votes
1 answer

Can't change background color of SimpleSettingsTile

I use flutter_settings_screens flutter plugin for settings screen of my mobile application and I can't change background of each setting. For example, I want to change background of SimpleSettingsTile. How can I do that ? Here is my code: import…
0
votes
4 answers

initializing variables before build in flutter?

I am trying to initialize a variable in the initstate. Before initializing null value is used in my scaffold. How can I wait for a variable then later load the build?I am using shared_preference plugin. This is my initstate: void initState() { …
cvsrt
  • 357
  • 4
  • 19
0
votes
1 answer

shared_preferences not working in release mode even after building with --no-shrink flag

I am using 'shared_preferences' plugin in my flutter project. The problem is that the app is working as expected in debug mode but not working correctly in release mode. I have tried building with the --no-shrink flag also but still it does not…
0
votes
1 answer

late initilization error shared prefrences in flutter?

even after i have intitialized there is an error : Late initialization error displayName here is the code where i have set the value: var displayName=jsondata["username"]; SharedPreferences prefs=await SharedPreferences.getInstance(); …
0
votes
1 answer

how to check if SharedPreferences file existed or not in flutter

my flutter application needs to check if there is a SharedPreferences file and if there value in SharedPreferences at the start of my application. here is my code : finally it generates the following error
nebi
  • 11
  • 4