'Flutter web local storage issue with Getx
I have a question. After logging in, I save the token with get storage, then when I redirect to a new page with the url launcher, the existing token is lost and sometimes I get this problem and sometimes I don't. Below is how I write and read get storage
{
final box = GetStorage();
box.write("token", nvResponseLogin.value.auth!.token);
}
{
final _box = GetStorage();
String? token = _box.read("token");
if (token == null) {
token = "";
}
}
Solution 1:[1]
- Basically it seems your code is not wrong.
- Make sure variable is 'box' or '_box'.
- Check the right token is saved or not before use. ex) print token right after saving the token to getStorage.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bernard Hur |
