Skip to content

How to handle errors thrown by generated providers? #3386

Answered by Colman
agufagit asked this question in Q&A
Discussion options

You must be logged in to vote

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(...);
    }
  },
);

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by agufagit
Comment options

You must be logged in to vote
1 reply
@Colman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants