qlevar_router icon indicating copy to clipboard operation
qlevar_router copied to clipboard

Add or remove routes in run Time

Open Gino1963 opened this issue 1 year ago • 1 comments

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

Gino1963 avatar Aug 14 '23 22:08 Gino1963

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())
]);

c-seeger avatar Jan 31 '24 15:01 c-seeger