From 0805da1b37cacee9fe8662bf39025a3284a346b5 Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 2 Nov 2023 09:57:01 -0600 Subject: [PATCH] Add back button fallback to go to /home if the view can not be popped --- lib/ui/common/controls/circle_buttons.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ui/common/controls/circle_buttons.dart b/lib/ui/common/controls/circle_buttons.dart index 3bddf06d..6f968eb5 100644 --- a/lib/ui/common/controls/circle_buttons.dart +++ b/lib/ui/common/controls/circle_buttons.dart @@ -109,7 +109,14 @@ class BackBtn extends StatelessWidget { icon: icon, bgColor: bgColor, color: iconColor, - onPressed: onPressed ?? () => Navigator.pop(context), + onPressed: onPressed ?? () { + final nav = Navigator.of(context); + if(nav.canPop()){ + Navigator.pop(context); + } else { + context.go(ScreenPaths.home); + } + }, semanticLabel: semanticLabel ?? $strings.circleButtonsSemanticBack, ); }