@@ -14,6 +14,8 @@ class TaskController extends GetxController {
1414 RxList <bool > isCompleted = < bool > [].obs;
1515 RxList <bool > useTime = < bool > [].obs;
1616 RxList <String > times = < String > [].obs;
17+
18+ // This variable stores the time the user recently checked.
1719 RxList <DateTime > checkedDateTime = < DateTime > [].obs;
1820
1921 RxInt editingIndex = (- 1 ).obs;
@@ -84,6 +86,8 @@ class TaskController extends GetxController {
8486 super .onInit ();
8587 }
8688
89+ // This function runs only the first time the app is turned on.
90+ // Compare the time they recently checked with the time they want the check turned off.
8791 void _firstCheck () {
8892 final currentTime = DateTime .now ();
8993 for (int i = 0 ; i < tasks.length; i++ ){
@@ -94,10 +98,18 @@ class TaskController extends GetxController {
9498 int minute = int .parse (times[i].substring (j+ 2 , j+ 4 ));
9599 Duration difference = currentTime.difference (checkedDateTime[i]);
96100 int daysDifference = difference.inDays;
101+
102+ // There are three things to consider.
103+ // 1. Checked at least 2 days ago.
97104 if (daysDifference > 1 ){
98105 isCompleted[i] = false ;
99106 break ;
100- } else if (daysDifference == 1 ){
107+ }
108+
109+ // 2. Checked 1 day ago.
110+ // Do not turn off the check only when the time they checked is later than the time they want the check turned off
111+ // and the current time is earlier than the time they want the check turned off.
112+ else if (daysDifference == 1 ){
101113 if (hour < checkedDateTime[i].hour || (hour == checkedDateTime[i].hour && minute <= checkedDateTime[i].minute)){
102114 if (hour > currentTime.hour || (hour == currentTime.hour && minute > currentTime.minute)){
103115 continue ;
@@ -109,7 +121,10 @@ class TaskController extends GetxController {
109121 isCompleted[i] = false ;
110122 break ;
111123 }
112- } else {
124+ }
125+
126+ // 3. Checked today.
127+ else {
113128 if (hour < currentTime.hour || (hour == currentTime.hour && minute <= currentTime.minute)){
114129 if (hour < checkedDateTime[i].hour || (hour == checkedDateTime[i].hour && minute <= checkedDateTime[i].minute)){
115130 continue ;
@@ -153,7 +168,11 @@ class TaskController extends GetxController {
153168 tasks.add ('' );
154169 isCompleted.add (false );
155170 useTime.add (false );
171+
172+ // Users can save three times when they want the check turned off.
173+ // Example) 080012001800
156174 times.add ('------------' );
175+
157176 checkedDateTime.add (DateTime .utc (1969 , 7 , 20 , 20 , 18 ));
158177 }
159178
0 commit comments