refactor: enhance navigation robustness by introducing popSafe and safePushNamedAndRemoveUntil methods and updating their usage.

This commit is contained in:
Achintha Isuru
2026-02-28 17:23:53 -05:00
parent c26128f1f2
commit 53b612851c
24 changed files with 481 additions and 334 deletions

View File

@@ -74,7 +74,9 @@ class _SessionListenerState extends State<SessionListener> {
// Only show if not initial state (avoid showing on cold start)
if (!_isInitialState) {
debugPrint('[SessionListener] Session error: ${state.errorMessage}');
_showSessionErrorDialog(state.errorMessage ?? 'Session error occurred');
_showSessionErrorDialog(
state.errorMessage ?? 'Session error occurred',
);
} else {
_isInitialState = false;
Modular.to.toClientGetStartedPage();
@@ -126,7 +128,7 @@ class _SessionListenerState extends State<SessionListener> {
TextButton(
onPressed: () {
// User can retry by dismissing and continuing
Modular.to.pop();
Modular.to.popSafe();
},
child: const Text('Continue'),
),

View File

@@ -65,7 +65,6 @@ class _SessionListenerState extends State<SessionListener> {
_sessionExpiredDialogShown = false;
debugPrint('[SessionListener] Authenticated: ${state.userId}');
// Navigate to the main app
Modular.to.toStaffHome();
break;
@@ -75,7 +74,9 @@ class _SessionListenerState extends State<SessionListener> {
// Only show if not initial state (avoid showing on cold start)
if (!_isInitialState) {
debugPrint('[SessionListener] Session error: ${state.errorMessage}');
_showSessionErrorDialog(state.errorMessage ?? 'Session error occurred');
_showSessionErrorDialog(
state.errorMessage ?? 'Session error occurred',
);
} else {
_isInitialState = false;
Modular.to.toGetStartedPage();
@@ -127,7 +128,7 @@ class _SessionListenerState extends State<SessionListener> {
TextButton(
onPressed: () {
// User can retry by dismissing and continuing
Modular.to.pop();
Modular.to.popSafe();
},
child: const Text('Continue'),
),