Skip to content

Commit 6e70658

Browse files
committed
fix(home): use router's real URL to gate the URL sync
`GoRouterState.of(context).matchedLocation` returns the route this widget was built under, not the currently active location. Inside a ShellRoute, that means it still reports `/` after the user has navigated to `/routes`, so the earlier guard didn't actually skip the URL replace and the user kept getting yanked back to the home screen when a plan resolved. Read the live URL from `router.routeInformationProvider.value.uri` instead, which always reflects the browser's current path.
1 parent 8e7c4b3 commit 6e70658

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/screens/trufi_core_home_screen/lib/src/widgets/home_screen.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,14 @@ class _HomeScreenState extends State<HomeScreen>
287287
// navigated away (e.g. to /routes) would replace the current
288288
// location back to '/?from_lat=...&to_lat=...', yanking them
289289
// out of the screen they switched to.
290-
final currentLocation = GoRouterState.of(context).matchedLocation;
291-
if (currentLocation != '/') return;
290+
//
291+
// Use the router's actual current URL (not GoRouterState.of(context),
292+
// which can return the route this widget was originally built under
293+
// even after the user has navigated elsewhere within a ShellRoute).
294+
final router = GoRouter.of(context);
295+
final currentPath =
296+
router.routeInformationProvider.value.uri.path;
297+
if (currentPath != '/') return;
292298

293299
final from = state.fromPlace;
294300
final to = state.toPlace;

0 commit comments

Comments
 (0)