SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
86 stars 22 forks source link

Add a way to await for route pushes #133

Closed Zazo032 closed 1 year ago

Zazo032 commented 1 year ago

With other navigation plugins, like go_router, you can do something like this:

onTap: () async {
  await context.go('/profile');
  callback();
}

Here, the callback() function runs after you pop the /profile route.

However, a similar approach with qlevar_router doesn't seem to work:

onTap: () async {
  await QR.to('/profile');
  callback();
}

In this case, the callback() function runs after the new route is pushed, without waiting for a pop.

Is there any way to achieve a similar behaviour with this plugin?

SchabanBo commented 1 year ago

Hi @Zazo032

As far as I know, waiting for a route with Nav2 is not currently possible. In the provided example, using the context.go method does not provide a future to wait for.

Unfortunately, I don't have any specific resources or methods on how to achieve this behavior. However, it would be a great feature to have, if you have any resource on how to do it, I would be happy to receive it.

In the meantime, you can consider alternative approaches to achieve similar behavior, such as using callbacks or custom event handling to trigger the desired actions after the route is complete.

Zazo032 commented 1 year ago

@SchabanBo it's not available in the official plugin, but there's a workaround that might help here too: https://github.com/flutter/flutter/issues/108764#issuecomment-1367171796

SchabanBo commented 1 year ago

This is now in version 1.10.0 More info Thanks for feature request and the info on how to do it 😀