showDateTimePicker function
Implementation
void showDateTimePicker(
BuildContext context, String? initTime, ValueChanged<String> onSelect) {
DateFormat _format = DateFormat('yyyy-MM-dd');
String pickTime = initTime ?? _format.format(DateTime.now());
showCupertinoModalPopup(
context: context,
builder: (context) => Container(
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(S.of(context).cancel)),
const Expanded(child: SizedBox()),
TextButton(
onPressed: () {
onSelect(pickTime);
Navigator.pop(context);
},
child: Text(S.of(context).sure)),
],
),
const Divider(
height: 1,
color: CommonColors.color_666666,
),
SizedBox(
height: 229,
child: CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
minimumDate: DateTime(1900, 1, 1, 0, 0),
maximumDate: DateTime.now(),
initialDateTime: DateTime.parse(pickTime),
onDateTimeChanged: (dateTime) {
pickTime = _format.format(dateTime);
},
),
)
],
),
));
}