[Solved] 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.

2023/08/21 22:36

Error

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] 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.
#0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:4347:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:4361:6)
#2 Element.getElementForInheritedWidgetOfExactType (package:flutter/src/widgets/framework.dart:4396:12)
#3 Provider._inheritedElementOf (package:provider/src/provider.dart:339:38)
#4 Provider.of (package:provider/src/provider.dart:293:30)
#5 ReadContext.read (package:provider/src/provider.dart:649:21)
#6 OrderMonitor._onData (package:robot_one/public/background/OrderMonitor.dart:20:18)
#7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#9 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#10 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#11 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#12 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

Solution

I am trying and will update when this error was solved.

Leave a Reply

Back to top