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
Just check boolean property mounted
of the state class of your widget before calling setState()
.
if (this.mounted) {
setState(() {
// Your state change code goes here
});
}
Or even more clean approach
Override setState
method in your StatelfulWidget
class.
class DateTimeButton extends StatefulWidget {
@override
void setState(fn) {
if(mounted) {
super.setState(fn);
}
}
}