-
for class generated providers, we can use guard() and ref.listen in widget, but what about function generated providers? how do we handle error and show on snackbar?
|
Beta Was this translation helpful? Give feedback.
Answered by
Colman
May 14, 2024
Replies: 2 comments 1 reply
-
Maybe: ref.listenSelf((previous, next) {
if (next.error != null) {
showSnackbar(...);
}
}); Context might be hard to get inside of your provider. Therefore, you could maybe just add this to your app widget: ref.listen(
getDataProvider,
(previous, next) {
if (next.error != null) {
showSnackbar(...);
}
},
); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
agufagit
-
will this work without |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe:
Context might be hard to get inside of your provider. Therefore, you could maybe just add this to your app widget: