[에러 내용]
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
위젯의 조상이 불안정하고, widget의 트리구조가 뭔가 불안정하다는 소리이다.
[에러 원인]
에러의 원인은 Flutter에서 async await
를 이용해 api호출을 하고 돌아왔을때, Navigator.of(context).pushAndRemoveUntil() 을 사용해 loginPage로 이동하려고 했다. 그런데 api호출을 안했을 경우엔 이동이 가능했지만, api호출 이후에 성공했을 때 이동하려고 하니 계속 같은 에러가 발생했다.
[에러 해결]
이것이 정답인지는 잘 모르겠지만,,,
에러가나기 전의 context를 변수로 지정해서 불러쓰는 경우로 해결했다.
var nv = Navigator.of(context);
로 지정한 후,
nv.pop();
///api호출 후
nv.pushAndRemoveUntil()
로 해결하면 된다.