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 or remove routes in run Time #139

Closed Gino1963 closed 2 months ago

Gino1963 commented 1 year ago

Hi.

I love add and remove routes !!!!!

I have a problem when I remove a route.

This is my stack tree:

stack1

I add the route "products":

QR: Route: Key: 11, Full Path: /dashboard/products was add to Key: 2 QR: Finding Match for /dashboard/products under root QR: adding Route: Key: 11, Full Path: /dashboard/products to the navigator with Key: 9

Now my stack tree is: stack2

If I remove de above route the debug message is:

QR: products is removed from Key: 2

and the stack tree is correct.

If I try to add the same route again the error appears:

The following assertion was thrown while handling a gesture: Assertion failed: file:///C:/Users/Biagio/AppData/Local/Pub/Cache/hosted/pub.dev/qlevar_router-1.10.0/lib/src/routes/qroute_internal.dart:70:14 qroute_internal.dart:70 !QR.treeInfo.namePath.containsKey(route.name) "Route name products (with path /dashboard/products) is already used by path /dashboard/products, please use a unique name for each route."

But the route has been removed ... I don't understand !!!!

Thanks in advance

Biagio

c-seeger commented 7 months ago

can confirm this issue:

QR.rootNavigator.addRoutes(<QRoute>[
  QRoute(path: '/test', builder () => const TestPage())
]);
QR.rootNavigator.removeRoutes(<String>['/test']);

// throws an error Path /test already exist, cannot add
QR.rootNavigator.addRoutes(<QRoute>[
  QRoute(path: '/test', builder () => const TestPage())
]);