3

**Example Image, we can't scroll to the time before current time & day

In the minimumDate param, we can't control the minimum time.

`  CupertinoDatePickerTest(                             
   onDateTimeChanged: (DateTime newdate) {
     print(newdate);
   },
   use24hFormat: false,
   maximumDate: DateTime.now().add(Duration(days: 2)),
   minimumDate:DateTime.now().subtract(Duration(days: 1)),
   minuteInterval: 1,
   mode: CupertinoDatePickerMode.dateAndTime,
   )`

1 Answers1

1

You can use minimumDate attribute inside CupertinoDatePicker widget, the following code will disable hours and minutes before the current time:

CupertinoDatePicker(
      minimumDate: DateTime.now(), //Min Date time is current time
  }

You can use maximumDate attribute as well if you would like to limit the maximum date:

maximumDate: DateTime.now().add(Duration(days: 2)), //Max Date is after tomorrow
Aziz
  • 461
  • 7
  • 18
  • 1
    Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others. – Jeroen Steenbeeke Feb 12 '21 at 09:21
  • 1
    Thanks Jeroen for your comment, I've edited it =) – Aziz Feb 12 '21 at 09:29