My app needs to login, then get the token to access the data. I already succeeded to get the token from the response but my question is how to store the token and then use the token on another page.
You can use shared_preferences
:
in pubspec.yaml:
dependencies:
shared_preferences: ^0.5.6+2
After getting the token:
addTokenToSF() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('token', token);
}
To retrieve the token:
getTokenFromSF() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String tokenValue = prefs.getString('token');
return tokenValue;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.