Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak by calling setState when widget not mounted or disposed off #90

Open
EffyCoder opened this issue Jul 21, 2020 · 1 comment

Comments

@EffyCoder
Copy link

EffyCoder commented Jul 21, 2020

> I/flutter (31014): package:google_map_location_picker/src/map.dart 92:7 | position = Lat: 18.5855067, Long: 73.742585 E/flutter (31014): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: setState() called after dispose(): MapPickerState#95b28(lifecycle state: defunct, not mounted) E/flutter (31014): 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 (31014): 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 (31014): 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 (31014): #0 State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1197:9) E/flutter (31014): #1 State.setState (package:flutter/src/widgets/framework.dart:1232:6) E/flutter (31014): #2 MapPickerState._initCurrentLocation (package:google_map_location_picker/src/map.dart:94:7) E/flutter (31014): <asynchronous suspension> E/flutter (31014): #3 MapPickerState.initState (package:google_map_location_picker/src/map.dart:119:55) E/flutter (31014): #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58) E/flutter (31014): #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5) E/flutter (31014): #6 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14) E/flutter (31014): #7 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18) E/flutter (31014): #8 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4527:16) E/flutter (31014): #9 Element.rebuild (package:flutter/src/widgets/framework.dart:4218:5) E/flutter (31014): #10 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4481:5) E/flutter (31014): #11 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5) E/flutter (31014): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14) E/flutter (31014): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18) E/flutter (31014): #14 _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:116:18) E/flutter (31014): #15 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2607:19) E/flutter (31014): #16 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:96:11) E/flutter (31014): #17 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1866:58) E/flutter (31014): #18 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15) E/flutter (31014): #19 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1866:13) E/flutter (31014): #20 RenderConstrainedLayoutBuilder.layoutAndBuildChild (package:flutter/src/widgets/layout_builder.dart:174:5) E/flutter (31014): #21 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:244:5) E/flutter (31014): #22 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (31014): #23 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:11) E/flutter (31014): #24 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:484:7) E/flutter (31014): #25 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7) E/flutter (31014): #26 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:399:14) E/flutter (31014): #27 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (31014): #28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (31014): #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (31014): #30 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:111:13) E/flutter (31014): #31 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1248:11) E/flutter (31014): #32 RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7) E/flutter (31014): #33 RenderProxyBoxMixin.performLayout (package

@imSaharukh
Copy link

Did u find any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants