Problem with "loading" in "when" #1177
Unanswered
jamolina2021
asked this question in
Q&A
Replies: 2 comments
-
Hi have the same issue, I have a similar code inside a button press, when I first press the button, it triggers loading(), network request and response and done, but data() is not triggered, I have to press the button 1 more time to fetch the data, which is fetched from the state (not network). TextButton(
onPressed: () {
ref.read(userProvider).map(
data: (data) => {
print(
'My data: ${data.username}'),
_isLoading = false
},
error: (e) => print('Error => $e'),
loading: () {
_isLoading = true;
});
}),
if (_isLoading) const CircularProgressIndicator(), And this is my future provider: final userProvider = FutureProvider<User>((ref) async {
return login(username, password);
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'll need more information. Could you share the version of Riverpod you're using and a minimal reproducible example? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
The loading doesn't seem to run when an error occurs.
For example, in the following code snippet:
Dio does a GET, but the Rest API server is stopped, so an error occurs: XMLHttpRequest error
The error parameter, after a certain time, is executed correctly, but the CircularProgressIndicator is not displayed in the time interval before the error parameter is executed.
Is this a bug?
Thanks for your help.
Regards,
Jose
Beta Was this translation helpful? Give feedback.
All reactions