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
2 answers

Save Bool Switch value with shared preferences - not working

I already followed a few examples on YT and also an example on pub.dev and I still have a problem with saving the Switch value from false to true. Regarding documentation, it looks like everything is ok but still, it is not working. The question is…
Christof
  • 27
  • 7
0
votes
1 answer

whenver i try to login in my app it shows login screen then goes to HomeScreen in flutter?

auth_service.dart import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import…
0
votes
1 answer

I`m trying to create data persistence using sharedpreferences, but i don`t exactly understand how SharedPreferences and Json work

I have a list of favourites: List favouriteData = []; And I also have a class of MetroStations with factory constructor to convert it to json and vice versa. class MetroStation { final String ukrName; final…
0
votes
1 answer

how to show loader until token is not checked in flutter?

Future main() async { WidgetsFlutterBinding.ensureInitialized(); runApp(MultiProvider(providers: [ ChangeNotifierProvider( create: (context) => UserProvider(), ) ], child: const MyApp())); } class MyApp extends…
0
votes
2 answers

Flutter Onboarding Screen Only Once With Splash Screen

I was working in Flutter to make an app and I only want the onboarding screen to be seen once by users. I have watched several videos showing how to do this, but the problem is my home screen will always be the Splash Screen. I am not sure how to…
0
votes
1 answer

SharedPreferences automatically get cleared when browser closed for flutter web

SharedPreferences is automatically cleared when browser is closed for flutter web. There is no problem when flutter web is reloaded but the problem comes when closing the browser and again when relaunched.
0
votes
2 answers

How to show updated list in shared preferences on UI - Flutter

I am making an app in a flutter in which I can select the contacts from phone book and saving them in shared preferences. No problem in data saving and retrieving but i m struggling with showing the updated list on my UI. It is showing the contacts…
sjDev
  • 41
  • 5
0
votes
2 answers

How to persist a List toDo = ['eat', 'sleep', 'code'] using Flutter's SharedPreferences please?

I am making a Tasks app where users type in their tasks for the day and they can check off a task once complete. To Store tasks, i am starting with an empty [ ] that gets populated with user's input. How do i save that data using shared preferences…
M.Nuh
  • 93
  • 1
  • 6
0
votes
2 answers

Flutter - Load variables with SharedPreferences

I am learning how to use the SharedPreferences library in Flutter. I created this code and I would like the counter and counter2 variables once I close and reopen the app to remain as the last save. However, when I reopen the app the counter and…
0
votes
1 answer

Widget Not Updating Information from shared_preferences in Flutter

I was making a settings page for my flutter app to save a single number. I used shared_preferences. It can save the value into saved_preferences, and it can retrieve the data, but when settings page is loaded again it doesn't load the data into the…
0
votes
2 answers

Shared Preferences Flutter - Save depending on Book Title

I'm working on a PDF viewer, where I'm trying to store the last page a user read to Shared Preferences as the Book_Title id (tid). When the user resumes reading he's redirected to where he previously left off depending on each book. The problem I'm…
0
votes
1 answer

Flutter How Save to List with Shared Preference

How can I save values to a list with SharedPreferences? It's a simple list with a date and one value, for example, a list of my weight and sorting the list by date.
Marcel
  • 75
  • 1
  • 9
0
votes
1 answer

How do I use sharedPreferences with booleans?

I am currently learning sharedPreferences and trying to set and get values to check if a button has been clicked or not. This is my class for sharedPreferences class UserSimplePrefences { static SharedPreferences? _preferences; static const…
Pannam
  • 482
  • 1
  • 3
  • 16
0
votes
2 answers

Flutter Shared Preferences, check if first run not working

I was originally following the code for the answer found here: Check if an application is on its first run with Flutter And I was incorporating it into the introduction_screen package on pub.dev I successfully have it loading the page for my…
Ten Digit Grid
  • 1,315
  • 4
  • 22
  • 43
0
votes
2 answers

How to use SharedPreferences with Bloc?

Here's my code: abstract class VolumeEven{} class VolumeUp extends VolumeEven{} class VolumeDown extends VolumeEven{} class VolumeMute extends VolumeEven{} class VolumeBloc extends Bloc { late SharedPreferences prefs; …
Hoang Phuc
  • 92
  • 6