Closed TolgaYld closed 3 years ago
Hi, can you please post the code you're using?
Hi, can you please post the code you're using?
Sorry bro, i know my code is terrible haha. I'm a beginner and I'm really embarrassed right now hahaha... 😅😆
onPressed: () async {
TimeRange result =
await showTimeRangePicker(
context: context,
start: TimeOfDay(
hour:
_saturdayTwoTo
.hour,
minute: DateTime(
now
.year,
now
.month,
now.day,
_saturdayTwoTo
.hour,
_saturdayTwoTo
.minute)
.add(Duration(
minutes:
15))
.minute,
),
end: TimeOfDay(
hour:
_saturdayTwoTo
.hour,
minute: DateTime(
now
.year,
now
.month,
now.day,
_saturdayTwoTo
.hour,
_saturdayTwoTo
.minute)
.add(Duration(
minutes:
30))
.minute,
),
disabledTime: TimeRange(
startTime:
_saturdayOneFrom,
endTime:
_saturdayTwoTo),
fromText:
_chooseOpeningHoursFrom,
toText:
_chooseOpeningHoursTo,
activeTimeTextStyle: TextStyle(
color: Colors
.white,
fontWeight:
FontWeight
.bold,
fontSize: 33),
timeTextStyle: TextStyle(
color: Colors
.white,
fontWeight:
FontWeight
.bold,
fontSize: 23),
selectedColor: Theme
.of(context)
.accentColor,
use24HourFormat:
true,
interval: Duration(
minutes:
_timeSteps),
ticks: _ticks,
);
setState(() {
_saturdayThreeFrom =
result
.startTime;
_saturdayThreeTo =
result
.endTime;
_addMoreOpeningHoursSaturdayThree =
"${_saturdayThreeFrom.format(context)} - ${_saturdayThreeTo.format(context)}";
});
},
I'm afraid I am a bit lost here. What is _saturdayTwoTo and _saturdayOneFrom?
Furthermore, supposed _saturdayTwoTo is a DateTime, you cannot use it in disabledTime, since it requires a TimeOfDay. But maybe it's just a typo?
Ich fürchte, ich bin hier ein bisschen verloren. Was ist _saturdayTwoTo und _saturdayOneFrom?
Außerdem ist angenommen, dass _saturdayTwoTo eine DateTime ist. Sie können sie nicht in disabledTime verwenden, da hierfür ein TimeOfDay erforderlich ist. Aber vielleicht ist es nur ein Tippfehler?
you can enter three time periods for each day of the week.
for example: _mondayOneFrom - _mondayOneTo (TimeOfDay) _mondayTwoFrom - _mondayTwoTo (TimeOfDay) _mondayThreeFrom - _mondayThreeTo (TimeOfDay)
I inserted this into a DateTime object as TimeOfDay.hour or minute TimeOfDay.minute and added the minutes (start: +15, end: +30), which in turn was inserted into a TimeOfDay object. I know, a bit complicated, but should normally work. 😃
I see... Watch out if you put stuff like now (DateTime.now()?) as you might get a day change if close to midnight etc. Maybe better put for example:
start: TimeOfDay(
hour: _saturdayTwoTo .hour,
minute: _saturdayTwoTo.minutes + 15,
)
No need to make it more complicated than necessary ;-)
I could not find a problem with the package so far. Please make sure you do not have overlaps or logic breaks ( e.g. set starttime to a disabled time, manipulate the start or enddates with other inputs etc).
If you still experience the problem, you can report it here.
I see... Watch out if you put stuff like now (DateTime.now()?) as you might get a day change if close to midnight etc. Maybe better put for example:
start: TimeOfDay( hour: _saturdayTwoTo .hour, minute: _saturdayTwoTo.minutes + 15, )
No need to make it more complicated than necessary ;-)
I could not find a problem with the package so far. Please make sure you do not have overlaps or logic breaks ( e.g. set starttime to a disabled time, manipulate the start or enddates with other inputs etc).
If you still experience the problem, you can report it here.
yes I always have to make it complicated. Oh man.... 😩
I thought, because it is an int, it can be over 60 minutes (80 or 90). that's why I took datetime ... 😖
thanksss (yes, i am a beginner 😅)
I see, well than maybe:
minute: _saturdayTwoTo.minutes >= 45? _saturdayTwoTo.minutes -45: _saturdayTwoTo.minutes +15,
I see, well than maybe:
minute: _saturdayTwoTo.minutes >= 45? _saturdayTwoTo.minutes -45: _saturdayTwoTo.minutes +15,
I tested it. the first way you showed works fine!!
thaaaankkkks!!!!!! 👍😄
As you can see, I select the last time, and normally my starting point ("start") should be 15 after the previous period (Thursday 19:30 - 22:30), i.e. 22:45 and my end point ("end") half an hour after the previous time span (Thursday 19:30 - 22:30) i.e. 23:00, but somehow that doesn't always seem to work reliably. why?
thanks in advance... :)