Angular 2 Dart – Dynamic Routing


Im working in Angular 2 Dart, but I should be able to translate any JS or TS examples.

1) How can I gain a list of all the registered routes?

2) How can I delete a route from the registered routes?

I know I can dynamically add via something like this:

  final Router router;

      Route(path: '/Page-0', component: Page0Route, name: 'Page-0')

But yet to work out listing and removing routes.


As far as I know there is currently no official way. The RouteRegistry contains the configured routes but it doesn’t provide public members to access them and in Dart you can’t access private fields like you can in TypeScript to work around this limitation.

The only workaround that I see is to extend the RouteRegistry class and add your custom implementation as provider for the RouteRegistry type, after ROUTE_PROVIDERS to ensure your custom implementation is taken instead.
I haven’t tried this yet though.

Answered By – Günter Zöchbauer

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.