Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect meta value returned when navigating with navigateNamed for Nested Routes #1882

Closed
carlosfiori opened this issue Mar 6, 2024 · 6 comments

Comments

@carlosfiori
Copy link

When navigating using navigateNamed for nested routes in AutoRoute, the meta value is being returned incorrectly. Instead of retrieving the meta value from the destination route, it is returning the meta value of the parent route.

Use Case

We use information from the meta to decide whether or not to show the BottomNavigationBar depending on the screen, but due to the incorrect meta being provided, the BottomNavigationBar is being displayed erroneously.

Reproduce

You can reproduce this issue by cloning this repository. When clicking the "go to profile" button on the home page, it should navigate to the profile screen without displaying the BottomNavigationBar.

It has been noticed that by adding a delay of 100 milliseconds, the meta value is returned correctly:

Future.delayed(const Duration(milliseconds: 100)).then((value) {
    // Now the value is correct
    print(context.topRouteMatch.meta['showBottomNav']);
});

Expected Behavior:

The returned meta value should correspond to the destination route, providing relevant information associated with that specific route.

Current Behavior:

The returned meta value corresponds to the parent route when retrieved immediately after navigation, which is incorrect. However, introducing a 100-millisecond delay before retrieving the meta value results in the correct meta value being returned.

Additional Information:

This issue affects the functionality of applications that rely on accurate meta information for nested routes. This can lead to incorrect rendering or behavior based on incorrect meta data.

@Milad-Akarie
Copy link
Owner

Hey @carlosfiori I just tried your example and everything seems to be working fine?

Mar-13-2024.6-24-07.PM.mp4

note: I've removed the delayed code in the above example

@carlosfiori
Copy link
Author

Hi @Milad-Akarie, thank you for your response.

The problem arises when navigating from the home page to the profile page for the first time.

I tested it in version 9.4 with Flutter 3.19.3, and the issue persists.

Gravacao.de.Tela.2024-03-14.as.10.33.44.mov

@Milad-Akarie
Copy link
Owner

@carlosfiori Believe it or not this issue took more than 20 hours of work, it's obviously a bigger issue than your use-case, I'm sure the fix will effect alot of open issues. anyways, confirm it works for you? v7.9.1

@carlosfiori
Copy link
Author

Hi @Milad-Akarie just test in 7.9.1 and work just great, thank you very much

@Milad-Akarie
Copy link
Owner

@carlosfiori 7.9.2 has a hot fix related to this issue

@carlosfiori
Copy link
Author

Great, I tested it on 7.9.2 and everything still works, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants