fix setState after disposed item

This commit is contained in:
Motia Benachour 2022-09-11 16:21:04 +01:00
parent 355b3cb4ef
commit 35a2d8ccdb
No known key found for this signature in database
GPG key ID: 070D55D6C32CF425

View file

@ -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<String> 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) {