From 35a2d8ccdb04a0bb297579eb240fb3e9c92938e7 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 16:21:04 +0100 Subject: [PATCH] fix setState after disposed item --- lib/screens/home/local_widgets/expenses_chart.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/screens/home/local_widgets/expenses_chart.dart b/lib/screens/home/local_widgets/expenses_chart.dart index 4cef78e..4b89f69 100644 --- a/lib/screens/home/local_widgets/expenses_chart.dart +++ b/lib/screens/home/local_widgets/expenses_chart.dart @@ -12,6 +12,14 @@ class ExpensesChart extends StatefulWidget { class ExpensesChartState extends State { int? touchedIndex; + bool disposed = false; + + @override + void dispose() { + disposed = true; + super.dispose(); + } + @override Widget build(BuildContext context) { List categories = @@ -24,6 +32,7 @@ class ExpensesChartState extends State { pieTouchData: PieTouchData(touchCallback: (event, pieTouchResponse) { if (pieTouchResponse == null) return; + if (disposed) return; setState(() { if (event is FlLongPressEnd || event is FlPanEndEvent) {