From bf15dcba8204f45fa2c464ac85f898bc88557626 Mon Sep 17 00:00:00 2001 From: Roscoe Date: Wed, 29 Jan 2025 10:13:18 +1100 Subject: [PATCH] Mounted check before repaint setState Adding a mounted check for the Chart widget repaint method, as it's possible for the repaint method to be calling setState while the widget has been disposed. --- lib/src/chart/chart.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/chart/chart.dart b/lib/src/chart/chart.dart index 0deb772..4cdb6d4 100644 --- a/lib/src/chart/chart.dart +++ b/lib/src/chart/chart.dart @@ -216,7 +216,9 @@ class ChartState extends State> with TickerProviderStateMixin { /// Asks the chart state to trigger a repaint. void repaint() { - setState(() {}); + if (mounted) { + setState(() {}); + } } @override