I am able to set the minimum date for the widget, however, I don't want the user to be able to select a time in the past. How do I ensure this? CupertinoDatePicker.
Sidenote: How do I make the '00' and '30' appear only once in the minutes wheel? Below is some relevant code snippets.
final minDate = DateTime.now();
final difference = 30 - minDate.minute % 30;
final initialDate = minDate.add(Duration(minutes: difference));
Stack(
children: <Widget>[
CupertinoDatePicker(
minimumDate: minDate,
maximumDate: minDate.add(Duration(days: 7)),
initialDateTime: initialDate,
minuteInterval: 30,
onDateTimeChanged: (dateTime) {
// Do stuff
},
),
Align(
alignment: Alignment.topRight,
child: CupertinoButton(
child: Text("Done"),
onPressed: () {
Navigator.of(context).pop();
}),
),
],
),