setState() called after dispose()

后端 未结 6 1936
迷失自我
迷失自我 2020-12-24 04:35

When I click the raised button, the timepicker is showing up. Now if I wait like 5 seconds and then confirm the time this error will occur setState() called after d

6条回答
  •  鱼传尺愫
    2020-12-24 04:51

    If it is an expected behavior that the Future completes when the widget already got disposed you can use

    if (mounted) {
      setState(() {
        selectedDate = new DateTime(selectedDate.year, selectedDate.month, selectedDate.day, picked.hour, picked.minute);
      });
    }
    

提交回复
热议问题