fix setState after disposed item
This commit is contained in:
parent
355b3cb4ef
commit
35a2d8ccdb
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue