gdelataillade / alarm

A Flutter plugin to easily manage alarms on iOS and Android
https://pub.dev/packages/alarm
MIT License
132 stars 86 forks source link

Fixed pickTime #125

Closed HARUM1122 closed 11 months ago

HARUM1122 commented 11 months ago

Changes Made Fixed a problem in the pickTime function where setting an alarm for today would sometimes set it for tomorrow. This happened when choosing a time later than the current time. The issue was caused by mistakenly using .copyWith with selectedDateTime, which already had an extra day. I updated the logic to use DateTime.now().copyWith instead for accurate behavior in both today and tomorrow scenarios.

Problem Previously, when users set an alarm for today and picked a later time, the alarm was mistakenly scheduled for tomorrow. This occurred when the selected time was after the current time.

Solution Changed selectedDateTime = selectedDateTime.copyWith to selectedDateTime = DateTime.now().copyWith to fix the issue. Now, when users set alarms for today, it works correctly without adding an extra day.

I've tested it out and now it's working fine. I've also replaced if-elif-else with switch statements.

gdelataillade commented 11 months ago

Hi @HARUM1122

Thanks for your contribution ! I really appreciate !