I have three providers for login => email, password, login. then I am refreshing login provider which is a future provider and will call the login API. now I need to see if the provider returns success then I will need to navigate to next page. But .when() is not waiting for the refreshing to finish. Its logging "loading..." in the console.
`
ref.watch(email.notifier).state =
emails.trim().toLowerCase();
ref.watch(password.notifier).state = passwords;
final loginstate = ref.refresh(login);
loginstate.when(data: ((data) {
// log(data + "here");
if (data == "Success") {
context.go('/home');
}
}), error: (error, stackTrace) {
// log(error.toString() + "here");
}, loading: () {
log("loading....");
});
`
I need to Navigate to the Home page upon successful API call.