Rabi
Rabi

Reputation: 21

make show time picker where the user can't select time in the past with flutter

I want to have a time picker where the user can't select a time in the past, like the show date picker where I can select the first date which I want and the last date I want the same thing for the time.

I tried a different package but it's not working. Just one package is time_picker_widget, which accepts to put a condition on the hour, but when I put the condition on minute, it disable all hour. I need to put the condition on a minute because I want the select time to be not in the past and it after at less one hour from now.

Upvotes: 0

Views: 1223

Answers (1)

Abdullah Sheikh Dibs
Abdullah Sheikh Dibs

Reputation: 26

you can try day_night_time_picker that allows you to set minMinutes or minHour

and here is an example how to use it:

                onPressed: () {
                    Navigator.of(context).push(
                      showPicker(
                        value: TimeOfDay.now(),
                        context: context,
                        onChange: (date) {},
                        minHour: TimeOfDay.now().hour.toDouble(),
                        minMinute: TimeOfDay.now().minute.toDouble(),
                      ),
                    );
                  },

Upvotes: 1

Related Questions