Flutter-intellij: `setState() called after dispose()` when selecting objects in the inspector

Created on 17 Jan 2018  路  3Comments  路  Source: flutter/flutter-intellij

2018-01-16 17:15:55,978 [  Thread-8]  ERROR - er.inspector.EvalOnDartLibrary - Error evaluating expression:
Unhandled exception:
setState() called after dispose(): _WidgetInspectorState#16c8a(lifecycle state: defunct, not mounted)
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().
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1080:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1097:6)
#2      _WidgetInspectorState.initState.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:474:7)
#3      WidgetInspectorService.setSelection (package:flutter/src/widgets/widget_inspector.dart:284:33)
#4      WidgetInspectorService.setSelectionById (package:flutter/src/widgets/widget_inspector.dart:260:12)
#5      Eval (evaluate:source:1:39)
#6      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1080:9)
#7      State.setState (package:flutter/src/widgets/framework.dart:1097:6)
#8      _WidgetInspectorState.initState.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:474:7)
#9      WidgetInspectorService.setSelection (package:flutter/src/widgets/widget_inspector.dart:284:33)
#10     WidgetInspectorService.setSelectionById (package:flutter/src/widgets/widget_inspector.dart:260:12)
#11     Eval (evaluate:source:1:39)
#12     Eval (evaluate:source:1:4)

com.intellij.openapi.diagnostic.Logger$EmptyThrowable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
    at io.flutter.inspector.EvalOnDartLibrary$1.received(EvalOnDartLibrary.java:98)
    at org.dartlang.vm.service.VmService.forwardResponse(VmService.java:410)
    at org.dartlang.vm.service.VmServiceBase.processResponse(VmServiceBase.java:432)
    at org.dartlang.vm.service.VmServiceBase$1.onMessage(VmServiceBase.java:99)
    at de.roderick.weberknecht.WebSocketReceiver.run(WebSocketReceiver.java:65)
bug inspector

Most helpful comment

And, after a reload, reload, restart, reload - without having interacted with the widget tree or inspector:

Error evaluating expression:
Unhandled exception:
setState() called after dispose(): _WidgetInspectorState#382ef(lifecycle state: defunct, not mounted)
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().
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1080:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1097:6)
#2      _WidgetInspectorState.initState.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:474:7)
#3      WidgetInspectorService.setSelection (package:flutter/src/widgets/widget_inspector.dart:284:33)
#4      WidgetInspectorService.setSelectionById (package:flutter/src/widgets/widget_inspector.dart:260:12)
#5      Eval (evaluate:source:1:39)
#6      Eval (evaluate:source:1:4)

com.intellij.openapi.diagnostic.Logger$EmptyThrowable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
    at io.flutter.inspector.EvalOnDartLibrary$1.received(EvalOnDartLibrary.java:98)
    at org.dartlang.vm.service.VmService.forwardResponse(VmService.java:410)
    at org.dartlang.vm.service.VmServiceBase.processResponse(VmServiceBase.java:432)
    at org.dartlang.vm.service.VmServiceBase$1.onMessage(VmServiceBase.java:99)
    at de.roderick.weberknecht.WebSocketReceiver.run(WebSocketReceiver.java:65)

All 3 comments

This was in Android Studio, with the not-yet-release M21 plugin.

I'm seeing this issue fairly consistently - on many / most app runs.

And, after a reload, reload, restart, reload - without having interacted with the widget tree or inspector:

Error evaluating expression:
Unhandled exception:
setState() called after dispose(): _WidgetInspectorState#382ef(lifecycle state: defunct, not mounted)
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().
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1080:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1097:6)
#2      _WidgetInspectorState.initState.<anonymous closure> (package:flutter/src/widgets/widget_inspector.dart:474:7)
#3      WidgetInspectorService.setSelection (package:flutter/src/widgets/widget_inspector.dart:284:33)
#4      WidgetInspectorService.setSelectionById (package:flutter/src/widgets/widget_inspector.dart:260:12)
#5      Eval (evaluate:source:1:39)
#6      Eval (evaluate:source:1:4)

com.intellij.openapi.diagnostic.Logger$EmptyThrowable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
    at io.flutter.inspector.EvalOnDartLibrary$1.received(EvalOnDartLibrary.java:98)
    at org.dartlang.vm.service.VmService.forwardResponse(VmService.java:410)
    at org.dartlang.vm.service.VmServiceBase.processResponse(VmServiceBase.java:432)
    at org.dartlang.vm.service.VmServiceBase$1.onMessage(VmServiceBase.java:99)
    at de.roderick.weberknecht.WebSocketReceiver.run(WebSocketReceiver.java:65)
Was this page helpful?
0 / 5 - 0 ratings