Skip to content

setState() called after dispose() #708

@kulaiyin

Description

@kulaiyin

Affected version

0.16.2

Flutter versions

3.24.4

No same issues found.

  • Yes, I search all issues but not found.

Steps to Reproduce

  1. webf自定义列表元素
  2. 在vue中使用该元素,
  3. 出现错误: Unhandled Exception: setState() called after dispose(): HTMLElementState#4a7e5(lifecycle state: defunct, not mounted)

Code example

none

Expected results

none

Actual results

E/flutter ( 7720): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: setState() called after dispose(): HTMLElementState#4a7e5(lifecycle state: defunct, not mounted)
E/flutter ( 7720): 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.
E/flutter ( 7720): 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.
E/flutter ( 7720): 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().
E/flutter ( 7720): #0 State.setState. (package:flutter/src/widgets/framework.dart:1167:9)
E/flutter ( 7720): #1 State.setState (package:flutter/src/widgets/framework.dart:1202:6)
E/flutter ( 7720): #2 HTMLElementState.addWidgetChild. (package:webf/src/widget/element_to_widget_adapter.dart:37:7)
E/flutter ( 7720): #3 new Future.microtask. (dart:async/future.dart:285:40)
E/flutter ( 7720): #4 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter ( 7720): #5 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter ( 7720):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions