美文网首页
Flutter setState() called after

Flutter setState() called after

作者: AR7_ | 来源:发表于2020-09-11 10:29 被阅读0次

    报错信息:

    This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

    Flutter中setState导致的内存泄漏——setState() called after dispose()

        if(mounted){
            setState(() {
          }
    

    相关文章

      网友评论

          本文标题:Flutter setState() called after

          本文链接:https://www.haomeiwen.com/subject/mcuvektx.html