-1

As a hobby and with the purpose of being better with provider I'm converting all the stateful widgets that I like into stateless widgets using provider. I perfectly understand simple cases, but now I have a problem with provider in builder. Here is where I use the provider (flipCardProvider.isBack)

Use Provider

And the error is the next one:

Provider Error

  • To improve the question I'd suggest you use code snippets instead of screenshots, there's a capability to outline them in code blocks. Same about error logs, it's worth having it as a separate blick – Maxim Saplin Dec 27 '21 at 18:53

1 Answers1

0

I don't think calling notifyListeners() in builder is the right place, there must be a general design flaw and misconception about how the framework works. Yet as a workaround you can wrap the call in Timer() or Future.delayed() to have the update scheduled right after build() completion:

Timer(Duration(seconds: 0, () => notifyListeners())
Maxim Saplin
  • 4,115
  • 38
  • 29
  • You are right! notifyListeners() in builder is not a right place! What I did (and it worked) is only delete all the notifyListeners() in builder! – Antonio Domínguez Dec 27 '21 at 20:13