Skip to content

how to use ref.listener's previous and next value? #969

Answered by rrousselGit
Shvet asked this question in Q&A
Discussion options

You must be logged in to vote

You do want to listen only to "next"
Your issue is, by the time you call ref.listen, your notifier is already in loading state, so you won't receive the loading event.

You can solve that by using a ConsumerStatefulWidget + initState by doing something like:

initState() {
  super.initState();
  if (ref.read(mainCategoryViewModel) is ParentCategoryLoading) {
    Future(() => showWaitingDialog(context));
  }
}

Replies: 1 comment 1 reply

Comment options

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

Answer selected by Shvet
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