You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you for creating this package. It is very useful.
Only problem is while setting initial time to current datetime, the start time is picked as nearest past hour, if a user does not select a time manually. e.g. If start time is 11:40, after tapping on Done, picked start time is 11:00.
I am using the following to round the minutes to the nearest interval. Please use it if you think it can be helpful to fix this issue. If you see any problems, let me know.
Solution:
// Remove minutes and seconds to prevent exception of cupertino picker: initial minute is not divisible by minute interval
int initialStartTimeMinute =
(initialStartTime.minute / interval).round() * interval;
initialStartTime = initialStartTime.subtract(Duration(
minutes: initialStartTime.minute, seconds: initialStartTime.second));
initialStartTime =
initialStartTime.add(Duration(minutes: initialStartTimeMinute));
if (initialEndTime == null) {
initialEndTime = initialStartTime.add(Duration(
days: mode == DateTimeRangePickerMode.time ? 0 : 1,
hours: mode == DateTimeRangePickerMode.time ? 2 : 0));
}
int initialEndTimeMinute =
(initialEndTime.minute / interval).round() * interval;
initialEndTime = initialEndTime.subtract(Duration(
minutes: initialEndTime.minute, seconds: initialEndTime.second));
initialEndTime =
initialEndTime.add(Duration(minutes: initialEndTimeMinute));
The text was updated successfully, but these errors were encountered:
This is working for me, thanks. I just added "!" to all initialStartTime and initialEndTime after the null checks.
So others are aware, this fixes a (in my opinion - bug) where the initialStartTime and initialEndTime removes the minutes when using DateTimeRangePicker(initialStartTime: x, initialEndTime: y).showTime()
Hi @longphanmn ,
First of all thank you for creating this package. It is very useful.
Only problem is while setting initial time to current datetime, the start time is picked as nearest past hour, if a user does not select a time manually. e.g. If start time is 11:40, after tapping on Done, picked start time is 11:00.
I am using the following to round the minutes to the nearest interval. Please use it if you think it can be helpful to fix this issue. If you see any problems, let me know.
Solution:
The text was updated successfully, but these errors were encountered: