Flutter setState() or markNeedsBuild() called when widget tree was locked

前端 未结 7 1424
忘掉有多难
忘掉有多难 2020-12-03 06:45

I am having trouble finding the source to this exception, and the app is quite complex so it is hard to show any relevant part of the code. This is my repository at the poin

相关标签:
7条回答
  • 2020-12-03 07:42

    There are couple of options used setState inside build method and context on initState

    Wrap your setState inside one of these

    WidgetsBinding.instance.addPostFrameCallback or Future.microTask() or Timer.run or Future.delayed(Duration.zero,

    Example:

      WidgetsBinding.instance
                  .addPostFrameCallback((_) {
                //valueNotifier.value = _pcm; //provider
                //setState
              });
    
    0 讨论(0)
提交回复
热议问题