cupertinoDatePickerModalPopupBuilder function
A FastDatePickerModalPopupBuilder that returns a modal popup that contains a CupertinoDatePicker;
Used when FastDatePicker.showModalPopup is true to show a CupertinoDatePicker in a modal popup via showCupertinoModalPopup .
Implementation
Container cupertinoDatePickerModalPopupBuilder(
BuildContext context, FastDatePickerState field) {
final FastDatePickerState(:value, :widget) = field;
DateTime? modalValue = value;
return Container(
color: CupertinoColors.systemBackground,
height: widget.height + 90.0,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CupertinoButton(
padding:
const EdgeInsetsDirectional.fromSTEB(24.0, 16.0, 16.0, 16.0),
child: Text(widget.modalCancelButtonText),
onPressed: () => Navigator.of(context).pop(null),
),
CupertinoButton(
padding:
const EdgeInsetsDirectional.fromSTEB(16.0, 16.0, 24.0, 16.0),
child: Text(
widget.modalDoneButtonText,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
onPressed: () => Navigator.of(context).pop(modalValue),
),
],
),
const Divider(
height: 1.0,
thickness: 1.0,
),
Container(
padding: const EdgeInsets.only(top: 6.0),
height: widget.height,
child: CupertinoDatePicker(
backgroundColor: widget.backgroundColor,
dateOrder: widget.dateOrder,
initialDateTime: value,
maximumDate: widget.lastDate,
maximumYear: widget.maximumYear,
minimumDate: widget.firstDate,
minimumYear: widget.minimumYear,
minuteInterval: widget.minuteInterval,
mode: widget.mode,
onDateTimeChanged: (DateTime value) => modalValue = value,
showDayOfWeek: widget.showDayOfWeek,
use24hFormat: widget.use24hFormat,
),
),
],
),
);
}