Even much better
if (GoRouter.of(context).canPop()) { GoRouter.of(context).pop(); } else { context.go('/dashboard'); }
So if there is no route, you can set a fallback!