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
1
vote
1 answer

Flutter: How to get/write data from/to shared preferences from action button's click using Awesome notifications?

I am using Awesome notifications to display notifications in my app. In the notifications, I have an action button, and when pressing it, the app is supposed to read and write some simple data from/to the memory of the phone using shared…
1
vote
1 answer

Integrate Provider with SharedPreferences to save and get Provider data

The list which stores the task data is integrated with provider for state management, but once I close the app and reopen it again, all tasks vanish. With resources, I got to know about SharedPreferences. How do I go about saving and getting the…
1
vote
3 answers

prefs.getString telling me that a String is a String?

I am trying to save a string to shared preferences and then retrieve it. However, my Android Studio tells me that there is an error. Specifically, it says: The argument type 'String?' can't be assigned to the parameter type 'String'. However, I…
1
vote
2 answers

What is wrong with my Shared preference? It wont remember my selected strokeWidth

I am trying to make a doodle app and im trying to get my selections on strokeWidth carry over to a reboot of the app. I tried the code below, but it doesnt seem to be working. Can someone tell me what im doing wrong or point me in the right…
1
vote
0 answers

SharedPreferences in Flutter

I'm having trouble getting certain items from an array and saving them in SharedPreferences. This is my login function, where it returns a body with all the user information. I store the whole array inside my SharedPreferences but I can't access the…
1
vote
4 answers

Flutter how can i set Auth token from flutter secure storage to dio header?

After login i setting user token to my user Secure storage. Like : Future login(AuthRequstModel model) async { try { Response response = await _dio.post(loginPath, data: model); if (response.statusCode == 200) { …
1
vote
2 answers

SharedPreference giving "Unable to establish connection on channel." when used inside flutter_background_service

I'm using flutter_background_service to start a service to fetch data from Cloud. It's working just fine in Android. But when I run on an iOS Simulator, I get the Above mentioned error. void syncData() async { …
1
vote
2 answers

Shared Preferences key value not changing

I want to write code that directs the user to a welcome page if it's the first time the app is being run. After the user logs in, any subsequent launches of the app direct the user to log in, skipping the welcome page. It seems that when I try to…
1
vote
1 answer

How to save an index of PageView and load it when reopening the app?

I want to save an index of PageView and load it when reopening the app. For example, if a user closes the app on page 2, the app should be started on page 2. I tried to implement this feature by using shared_preferences and provider. However, the…
1
vote
0 answers

flutter web save page stack after refresh a page

I am trying to restore pages stack after a browser refresh button pressing. Using onGenerateRoute on MaterialApp I can restore the single page, even with arguments using SharedPrefences api and Firestore data but when I press the browser back…
blob
  • 439
  • 8
  • 21
1
vote
0 answers

Why the Snackbar is re-shown in the below code when I am clearly setting the condition that should show the Snackbar to false in Flutter?

I have created a custom button widget in flutter called BottomButton. Since I feel that the implementation of the custom widget is not necessary for the question, I have simply omitted it. BottomButton( text: "Tap to Login", …
1
vote
1 answer

I can only get the value from shared preference after exiting the app using back button

there are two ways to exit from our Android (Flutter) app, we can press back button repeatedly or we can just press home button if a user press home button (not back button), then the app will be in the background. and I send FCM (Firebase Cloud…
1
vote
0 answers

I want to add bookmarks or favorites feature in flutter

The code below is my button part code. When this button is clicked, I want to display the color of the border of the bookmarked buttons on the "Page Selection Page (code below)" to change color. Actually the most important part is using…
1
vote
2 answers

I'm trying to implement a favorites feature locally in flutter that works both inside the page and on the select page

I'm trying to add a favorites feature with flutter. If you activate it by clicking the Favorites button inside the page, you need to implement it so that the Favorites page marked as Favorite appears in the page selection window. getx was too…
1
vote
2 answers

The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't in Text widget

I am trying to display the name and email of the person when he logs in to the profile screen using Getx Column( children: [ Text( …