E / flutter(17200):[ERROR:flutter / lib / ui / ui_dart_state.cc(157)]未处理的异常:NoSuchMethodError:方法'findRootAncestorStateOfType'被调用为null。
答案 0 :(得分:0)
在构建窗口小部件之前使用上下文时,会导致此错误。
尝试以下代码:
WidgetsBinding.instance.addPostFrameCallback((_) {
// put the code here where you are using context.
});
我希望这会有所帮助,如有任何疑问,请发表评论。 如果此答案对您有帮助,请接受并对其进行投票。
答案 1 :(得分:-1)
在调用Navigator.of(context).pop()
之后执行一些代码时,出现此错误。您的BuildContext
对象为空。