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

Time:03-05

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?

CodePudding user response:

We cannot limit the timer. We can instead check if the current picked time is equal to our expectations. If not so show the user a dialog or a message to re enter the data and the current data entered is not available. Maybe this works for you.

  • Related