124 questions
2
votes
0
answers
90
views
Flutter app stuck when SharedPreferences.getInstance() called
I updated my Flutter app to compile with Google Plays 16KB page size policy. I have changed several packages versions. Now I am getting an Platform exception error and app is stuck on splash.
The ...
1
vote
0
answers
59
views
I’m getting the following error when trying to use the `shared_preferences` package in a Flutter desktop app (with multiple windows /secondary engine)
It looks like the plugin cannot establish a connection to the method channel.
From what I understand, shared_preferences relies on a platform channel that may not be registered when using multiple ...
1
vote
0
answers
98
views
A way to mock SharedPreferencesAsync/SharedPreferencesWithCache in flutter
I have seen SharedPreferences.setInitialMockValues or something like that. Still, since SharedPreferences has become a legacy API and with the new SharedPreferencesAsync/SharedPreferencesWithCache API,...
0
votes
0
answers
32
views
Why does my flutter script for clearing preferences cause seemingly unrelated errors?
I'm working on an app that utilizes some preferences for login. For this, I'm using the shared_preferences package. The preferences work fine, but when I made a script to clear them for testing ...
0
votes
0
answers
66
views
Flutter switch transition issue with Riverpod and shared preferences
I have a simple switch in my app that I want to update and save in my shared preferences.
I am using Riverpod to query my shared preferences.
The issue is that if I just use setState() without shared ...
0
votes
1
answer
139
views
Persiste theme mode with Riverpod
I'm trying to persiste ThemeMode using Riverpod and shared_preferences packages
Here is what I did in themeNotifier:
import 'package:flutter/material.dart';
import 'settings_repository.dart';
import '...
1
vote
2
answers
919
views
Proguard rules to avoid Shared Preferences Not Found in flutter
I use the awesome_notifications plugin in my Flutter app. In debug mode everything runs fine, but in production the app crashes at launch.
So I did bunch of testing and finally found out that in ...
0
votes
1
answer
189
views
How can I clear/dispose Shared Preferences when logging out of a Flutter app?
Sorry my bad English in advance.
I would like to find out how I can clear SharedPreferences when I log out of the application. In my case, the Logout button is on screen 1 (HomePage).
On screen 2, I'm ...
2
votes
0
answers
110
views
App already has local storage (sharedPrefrences) on fresh install flutter
I have this class rendered when the first time lauching an app
import 'package:distributor_obat_semarang/screens/login.dart';
import 'package:distributor_obat_semarang/screens/splash.dart';
import '...
0
votes
1
answer
538
views
Cant Manage to use correctly SharedPreferences on my Main.dart on Flutter?
I've been learning Flutter and learned this to improve usage with Pub.dev package Shared Preferences,
To sum up, it is to create a service that I can consume and work in a better way all around my app ...
0
votes
3
answers
1k
views
SharedPreferences Flutter.. Set Expiration Time
I am making a application in Flutter.
I have a access token coming from an API which I save in shared preferences for session management and authentication.
But here the catch is that this token ...
0
votes
1
answer
243
views
Flutter SharedPreferences Error on iOS and macOS
I am trying to run my Flutter application via Xcode and I keep getting the error
Warning: Unable to create restoration in progress marker file (11db)
It seems to happen on line 18 of the file '...
1
vote
1
answer
207
views
Flutter shared_preferences has "no guarantee that writes will be persisted to disk after returning". What EXACTLY does that mean?
The Flutter shared_preferences package comes with a warning that says:
there is no guarantee that writes will be persisted to disk after returning
Because of that people often recommend using ...
0
votes
1
answer
66
views
Non-nullable instance of SharedPreferences must be initialized in Flutter
I want to store and read details using local storage. I have added dependencies in the pubspec.yaml file and imported the shared_preferences class.
Hint showed to add late before SharedPreferences ...
0
votes
1
answer
677
views
How to Cache Selected Items from a Multi-Select Dropdown in Flutter
I have a Flutter application where users can select multiple options from a dropdown using the dropdown_search package. I would like to add a feature where the selected items are cached locally, and ...
0
votes
2
answers
328
views
The default theme is displayed for a moment when the app is launched. [Flutter]
Themes are switched using RIverpod; ThemeMode is saved using Shared Preferences. They are working fine.But when I set the default values as follows, the default theme is shown for a moment at the ...
0
votes
1
answer
185
views
Flutter shared_preferences sometimes not initialized when using the Singleton pattern - one instance across all files
So I have created a class for using shared_preferences with a singleton pattern, so I can use one instance across all my files.
And almost all of the time it works flawlessly, but occasionally, when I ...
0
votes
1
answer
129
views
Is it possible to allow multiple entities to use one global ChangeNotifier in flutter?
I'm designing an application that allows users to view content of their desired integrations (this could be anything such as twitter, bbc.co.uk etc...). I have a settings page in which I would like ...
0
votes
3
answers
419
views
how can i get value instead of Instance of 'Future<String>'
I'm using flutter and I am trying to get a value from shared_preferences for firebase.
i checked my cord doesn't work and uid was " Instance of 'Future' ".
the solution i found was using ...
0
votes
2
answers
441
views
shared_preferences throws exception when trying to save a string on ios
I can not save a string using shared_preferences plugin for iOS.
Future<Map<String, dynamic>> login(String username, String password) async {
Map<String, dynamic> data = await ...
0
votes
2
answers
331
views
Inappwebview and Shared Preference URL I can't assign the url stored in Shared Preference
good evening. I'm trying to assign a Shared Preference url but the page doesn't load, it only works when I assign the value to a variable like this:
String url = 'https://www.youtube.com/';
I have ...
1
vote
1
answer
308
views
Why is the `await` keyword often omitted when using the shared_preferences plugin?
While using shared prefs plugin it's common to explore code like below
void saveList() async {
final prefs = await SharedPreferences.getInstance();
prefs.setStringList("listKey", aList); ...
0
votes
0
answers
317
views
Flutter module used in iOS native app: Unhandled Exception with shared_preferences initialization - PlatformException(channel-error)
I have been searching on Stack Overflow for a long time, but I haven't found a suitable solution. Most of the answers either don't work or don't provide a clear answer, such as this post: ...
0
votes
1
answer
2k
views
How to share persistent storage between isolates in flutter?
I am using android_alarm_manager_plus to run a dart isolate. In that isolate, I modify some data and I want those changes to reflect in the main isolate. Likewise, I want changes made in the main ...
0
votes
1
answer
254
views
How to store response of an api in cache and call api after every 12 hours? [closed]
I have an api call that have list of images and text in json response, i want to store json in local and use it in the ui, The api should be called after every 12 hours and save data in cache or the ...
1
vote
0
answers
46
views
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-...
1
vote
2
answers
1k
views
using Shared preferences with a change notifier
I'm trying to understand how to use shared preferences with a change notifier. I've created a basic app and I want to save a bool and a string from the change notifier using shared preferences.
here ...
1
vote
2
answers
1k
views
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<void> main() async {
await GetStorage.init();
runApp(const App(...
0
votes
1
answer
101
views
I tried to get name from SharedPreferences method but when run code show null value in the console in flutter How to solve it?
In my code at the home page fetch user name from firestore database and that's display nicely in UI. I want pass that name to shared preference function and store there and use that name in another ...
1
vote
1
answer
41
views
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 ...
1
vote
1
answer
337
views
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 ...
1
vote
1
answer
540
views
Saving list of objects locally on device with shared_preferences in Flutter
I created an app that can send IR signals in which you can add IR signals yourself. The signals are saved in an object list named Item with items as the objects. I want the names and signals saved ...
0
votes
2
answers
254
views
String stored in Shared Preferences is not loading at first in Flutter app
I have a project management app where the details of the project are displayed after pressing the 'more' icon button on a card. The details to be displayed include the project name and due date that ...
0
votes
1
answer
26
views
Not able to see sharedpref folder in phone as well Getting this error :Exception has occurred. _CastError (Null check operator used on a null value)
Hello Guys I am new to flutter and working on a flutter project. Below is the code of my splash screen. What I am doing is when the app launched we get the data from sharedpreference if we got the ...
0
votes
1
answer
148
views
Why does Flutter shared_preferences download an older version without null safety?
I'm trying to add shared_preferences to a Flutter project. By default, version 0.5.7+3 is downloaded which isn't null safe.
Adding the latest version, 2.0.15, gets the following error:
Running "...
0
votes
2
answers
618
views
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 ...
0
votes
1
answer
583
views
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/...
0
votes
1
answer
18
views
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<MetroStation> favouriteData = <MetroStation>[];
And I also have a class of MetroStations with factory constructor to convert it to json and vice versa.
...
0
votes
1
answer
386
views
how to show loader until token is not checked in flutter?
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(MultiProvider(providers: [
ChangeNotifierProvider(
create: (context) => UserProvider(),
)
], ...
0
votes
2
answers
2k
views
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 ...
1
vote
1
answer
2k
views
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 ...
3
votes
1
answer
1k
views
Unhandled Exception: type 'Null' is not a subtype of type 'List<dynamic>' 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 ...
0
votes
1
answer
1k
views
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 ...
1
vote
3
answers
298
views
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 ...
1
vote
2
answers
116
views
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 ...
0
votes
2
answers
267
views
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 ...
0
votes
2
answers
326
views
How to persist a List<String> 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. ...
0
votes
2
answers
773
views
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.
...
0
votes
1
answer
495
views
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 ...
1
vote
0
answers
51
views
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 ...