I was testing my app where I'm using this library but it was throwing the failed assertion error. It was around 10:13 PM when i was doing the test. Below is the method where assertion was failing
I followed where the above method was being called and i found one of it usages below.
void initState() {
var startTime = widget.start ?? TimeOfDay.now();
var endTime = widget.end ?? startTime.replacing(hour: startTime.hour + 3);
Something interesting above. Since it was 10 PM (22 in 24hr clock system), if you add three hours, you get 22+3 = 25. Thus the value that will be passed to startTime.replacing(hour: startTime.hour + 3) is 25 hence causing the failure.
I think the solution is after adding the 3 hours, we should check if the hour is >= 24, we return 23.
I was testing my app where I'm using this library but it was throwing the failed assertion error. It was around 10:13 PM when i was doing the test. Below is the method where assertion was failing
I followed where the above method was being called and i found one of it usages below.
Something interesting above. Since it was 10 PM (22 in 24hr clock system), if you add three hours, you get
22+3 = 25
. Thus the value that will be passed tostartTime.replacing(hour: startTime.hour + 3)
is25
hence causing the failure.I think the solution is after adding the 3 hours, we should check if the hour is >= 24, we return 23.