Realank / flutter_datetime_picker

a date time picker in flutter
MIT License
617 stars 727 forks source link

showDateTimePicker max limit for hour is not setting for the same day, #192

Open aifrosals opened 4 years ago

aifrosals commented 4 years ago

if I set the min and max time like this for showDateTimePicker

 minTime: DateTime(2020,10,26,12,0),
 maxTime: DateTime(2020,10,26,19,59),

it gives me the min time of 12th hour but it is still giving me 23:59 for the maxTime, although I set it to 19.59

pawangjain commented 3 years ago

Is there a workaround or fix?

JunevaYang commented 3 years ago

i have the same problem, when the set time interval is less than one day

racknoris commented 3 years ago

@JunevaYang Did you find a workaround?

JunevaYang commented 3 years ago

@JunevaYang Did you find a workaround?

not

racknoris commented 3 years ago

@JunevaYang You can use this fork: https://github.com/yu3fms/flutter_datetime_picker He solved this problem, I used it and it works great

JunevaYang commented 3 years ago

@JunevaYang You can use this fork: https://github.com/yu3fms/flutter_datetime_picker He solved this problem, I used it and it works great

thx

pawangjain commented 3 years ago

I tried the fork: https://github.com/yu3fms/flutter_datetime_picker with the below code.

But the maxTime does not restrcit the time to plus 4 hours. It shows till the midnight of the same day.

DatePicker.showDateTimePicker(
        context,
        showTitleActions: true,
        minTime: DateTime.now(),
        maxTime: DateTime.now().add(Duration(
          hours: 4,
        )),
        onChanged: (date) {
          print('change $date');
        },
        onConfirm: (date) {
          print('confirm $date');
        },
        currentTime: DateTime.now(),
        locale: LocaleType.en,
      );
    },
    child: Text(
      'Select Time within 4 Hours',
    ));

Is there anything i am missing or doing wrong?

trinanda98 commented 3 years ago

Hey guys it is still not working for me, has anyone found the solution?