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
Ensure `/alarmScreen` navigates back to `/home` when it is opened while `ScheduleBloc.state.status` is already `ScheduleStatus.notExists`, instead of leaving the user on the loading spinner.
- The issue covers stale notification, deleted schedule, and already-ended schedule entry paths.
10
+
-`AlarmScreen` currently handles transitions into `notExists` in `lib/presentation/alarm/screens/alarm_screen.dart`, but its `BlocListener.listenWhen` only fires when the previous status was not `notExists`.
11
+
- When the alarm route is built with an already-`notExists` state, no listener event fires and the `BlocBuilder` falls through to the loading scaffold.
12
+
- Finish flow uses `_navigateAfterFinish`, `_pendingEarlyLateSeconds`, and `_pendingIsLate` to route to `/earlyLate` after `ScheduleFinished` emits `notExists`; this path must remain higher priority than the home fallback.
13
+
- Existing alarm widget coverage lives in `test/presentation/alarm/screens/preparation_flow_widget_test.dart`.
14
+
15
+
## Decisions
16
+
- Treat an already-`notExists` state on alarm route entry as terminal for `/alarmScreen`.
17
+
- Trigger the fallback with a post-frame callback, because navigation should not happen synchronously during build.
18
+
- Keep the existing transition listener for active schedule flows that later become `notExists`.
19
+
- Preserve `_navigateAfterFinish` handling so manual or dialog finish still routes to `/earlyLate`.
20
+
- Scope the implementation to `AlarmScreen` and alarm widget tests; no bloc behavior change is needed.
21
+
22
+
## Steps
23
+
1. In `AlarmScreen`, add a helper such as `_navigateHomeAfterFrameIfMounted(BuildContext context)` to centralize safe post-frame home navigation.
24
+
2. In the `BlocBuilder` branch for `ScheduleStatus.notExists`, check that `_navigateAfterFinish` is false, clear transient alarm UI state, stop the UI ticker, and schedule the home navigation after the current frame.
25
+
3. Leave the current `BlocListener` in place for `ongoing`, `started`, or `upcoming` states that later emit `notExists`.
26
+
4. Make sure the loading scaffold remains only for genuinely unresolved statuses, especially `ScheduleStatus.initial`.
27
+
5. Add a widget test that seeds the alarm bloc with `const ScheduleState.notExists()` before pumping `/alarmScreen`, then expects `/home`.
28
+
6. Add a stale-notification-style widget test with a stream that emits `null` while the bloc is already `notExists`, then confirms `/home` and no finish-use-case call.
29
+
7. Re-run existing finish navigation tests, especially manual finish and completion dialog finish cases, to confirm `/earlyLate` remains the result when `_navigateAfterFinish` is pending.
30
+
31
+
## Validation
32
+
-`flutter test test/presentation/alarm/screens/preparation_flow_widget_test.dart`
0 commit comments