So I'm trying to pick a date with a DatePicker package from inside a showDialog
using Bloc.
Here's the code that shows the Dialog
:
onPressed: () {
showDialog(
context: context,
barrierDismissible: true,
child: _buildEditDialog(context, arguments),
);
},
And here's the Dialog
's content:
void _openCalendarPicker(BuildContext context, SearchHotelArguments arguments) async {
final DateTime dateTimeNow = DateTime.now();
final List<DateTime> picked = await DateRagePicker.showDatePicker(
context: context,
initialFirstDate: arguments.checkInDate ?? dateTimeNow,
initialLastDate: arguments.checkOutDate ?? dateTimeNow.add(Duration(days: 1)),
firstDate: dateTimeNow,
lastDate: dateTimeNow.add(Duration(days: 365 * 10)));
if (picked != null && picked.length == 2) {
context.read<HotelChangeParamsBloc>().setCheckInDate(picked[0]);
context.read<HotelChangeParamsBloc>().setCheckOutDate(picked[1]);
}
}
Now, the issue here is that from a Dialog
I open a popup with the DateRangePicker
, pick the Date
and submit it but on the Dialog
the date stays the same as it was previously. And if I close and re-open the Dialog
I can see that there was a change in the date. So the Dialog
is not refreshing the data by itself(unless I re-open it).
Does anyone know how I can refresh the Dialog with the new Date
from the DateRangePicker
?