icemanbsi / searchable_dropdown

MIT License
107 stars 162 forks source link

'Unhandled Exception: setState() called after dispose()' when I use this library on modalBottomSheet #61

Closed wilyanto closed 3 years ago

wilyanto commented 4 years ago

I got this kind of error when using this libray.. even if I didn't choose anything from the list (just clicking the close button)

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: setState() called after dispose(): _SearchableDropdownState#2df43(lifecycle state: defunct, not mounted) E/flutter ( 6092): 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 ( 6092): 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 ( 6092): 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().

charleshoong97 commented 3 years ago

Same goes here, is there any solution to this?

charleshoong97 commented 3 years ago

I solved the problem by added scaffold global key to the searchableDropDown

wilyanto commented 3 years ago

thankyou Charles, problem solved..