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)
And the error is the next one:
CodePudding user response:
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())