Open speedlightwp opened 5 years ago
中文:请问解决了吗?我的问题是:
setState() called after dispose(): BaseChartState
English: Has it been resolved?
setState() called after dispose(): BaseChartState
I am facing with the same issue . I am using charts in a tab view.
I am facing with the same issue . I am using charts in a tab view.
confirmed. also getting this error when used inside a tab
I have the same issue, using a TimeSeriesChart with stacked bars, in a SliverList.
Stacktrace:
I/flutter (10650): When the exception was thrown, this was the stack:
I/flutter (10650): #0 State.setState.
I am using BottomNavigation with PageView and Charts Flutter (charts_flutter: ^0.6.0). I realise if I use pageController.jumpToPage(index), it will cause the error setState() called after dispose(): BaseChartState. If I change to pageController.animateToPage, occasionally it will produce the error.
flutter: ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════ flutter: The following assertion was thrown during a scheduler callback: flutter: setState() called after dispose(): BaseChartState#64182(lifecycle state: defunct, not flutter: mounted, tickers: tracking 0 tickers) flutter: This error happens if you call setState() on a State object for a widget that no longer appears in flutter: the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error flutter: can occur when code calls setState() from a timer or an animation callback. The preferred solution flutter: is to cancel the timer or stop listening to the animation in the dispose() callback. Another flutter: solution is to check the "mounted" property of this object before calling setState() to ensure the flutter: object is still in the tree. flutter: This error might indicate a memory leak if setState() is being called because another object is flutter: retaining a reference to this State object after it has been removed from the tree. To avoid memory flutter: leaks, consider breaking the reference to this object during dispose().
I need to edit base_chart_state.dart file (line 72):
@override void requestRebuild() { if(mounted) setState(() {}); }
After adding if(mounted), it solves the problem.