Angular: Invalid argument(s): Route generator for "…" was not included in parameters passed

Issue

I am using child route configuration with parameters (AngularDart, package angular_router: ^1.0.2) and the following error occur:

EXCEPTION: Invalid argument(s): Route generator for “chave” was not
included in parameters passed.

What Am I doing wrong?

The @RouteConfig definitions are:

In Root

@RouteConfig(const [
  const Redirect(path: '/', redirectTo: const ['Painel']),
  const Route(path: '/painel', name: 'Painel', component: PainelComponent, useAsDefault: true),
  const Route(path: '/empresas/...', name: 'Empresas', component: EmpresasComponent),
  const Route(path: '/iniciativas', name: 'Iniciativas', component: IniciativasComponent),
])

In Parent EmpresasComponent (pass param to child EmpresaDetalheComponent)

@RouteConfig(const [
  const Route(path: '/empresa/:chave', name: 'EmpresaDetalhe', component: EmpresaDetalheComponent,
      useAsDefault: true),
])

The problem occurs when Parent is called from Root basead config definitions, even without calling the child that has the parameter.

Detail:

Navigation should work like this:
Root >>> Parent >>> Child (has param) = OK

But the param is requerid here: Root >>> Parent = Error, even no parameter is passed to the parent, only the child requires

What Am I doing wrong?

Solution

I found the reason this problem.

Actually, if useAsDefault: true is in a route URL with parameter (p.e. /:param), this problem occurs.

The workaround is define another route URL without parameter as useAsDefault: true

Answered By – Muka

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *