'How to limit the timing that can be picked from Cupertino date picker in Flutter?

Currently, this is how my Cupertino date picker look like

enter image description here

My code is as shown:

CupertinoDatePicker(
                      initialDateTime: DateTime.now(),
                      onDateTimeChanged: (val) {
                        setState(() {
                          dateSelected = val;
                        });
                      })

How can I make it such that I only allow the user to pick timing after 6 pm and before 3 am, every day?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source