2

so i build a alertdialog that contain a field to pick date and his code i put it on Future methode but setState flutter don't recognize it so any suggestions and of course this function outside the main class and when i move it inside the class it won't appear to alertdialog of course

Future<Null> _selectDate(BuildContext context) async {
 final DateTime picked = await showDatePicker(
     context: context,
     initialDate: selectedDate,
     firstDate: DateTime(2015, 8),
     lastDate: DateTime(2101));
 if (picked != null && picked != selectedDate)
   setState(() {
     selectedDate = picked;
   });
}

1 Answers1

1

When you use setState, it won't effect inside the dialog so you should use what is explained in this post's answer: https://stackoverflow.com/a/57240941/6378949

Mehmet Ali Bayram
  • 7,222
  • 2
  • 22
  • 27