I'm new to flutter is there a way to store id value from http response which can be accessed from any page ?. When login the response comes with an ID, I needed that id in various pages in flutter. Is it possible to store it and get the scope from all over the application>
Asked
Active
Viewed 44 times
1 Answers
1
Use SharedPreferences
to persist application related data. This would be cleared once user clears data of the app.

Arvind
- 724
- 5
- 6
-
when i added the sharedpref like this, ```shared_Id() async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('userId', (_login.id).toString()); print('hello'); } ``` I'm getting this error.. ** shared_Id() async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setString('userId', (_login.id).toString()); print('hello'); } ** – Ananthakrishna Oct 19 '20 at 17:52
-
I do not see any error, please edit your question and place your logs over there. – Arvind Oct 19 '20 at 17:55
-
Also, take a thorough search before making a duplicate of it – Arvind Oct 19 '20 at 17:55
-
I'm sorry thanks for the information. I got it correct.! – Ananthakrishna Oct 20 '20 at 09:30