'Flutter + auto_route. No route generated for a flutter package project

I created a Flutter-Package-Project and tried to generate the project route using auto_route, but unfortunately no route will be generated, but also no errors, just:

[INFO] Succeeded after 83ms with 0 outputs (0 actions)

My AutoRoute definition looks like:

    @MaterialAutoRouter(
      replaceInRouteName: 'Page,Route',
      routes: <AutoRoute>[
        AutoRoute(page: ItemsListPage, initial: true),
        AutoRoute(path: ':itemId', page: ItemDetailPage, fullMatch: true),
      ],
    )
    class $ItemsRouter {}

I specified all dependencies in the pubspec.yaml:

    dependencies:
      ...
      auto_route: ^2.2.0
      ...
    
    dev_dependencies:
      ...
      auto_route_generator: ^2.1.0
      build_runner: ^2.0.6
      ...

And I run flutter packages pub run build_runner build from the package project.

Maybe someone has an idea, what I'm doing wrong?



Solution 1:[1]

It looks like a bug in this row:

AutoRoute(path: ':itemId', page: ItemDetailPage, fullMatch: true),
                 ^^^^^^^ 

I think it must be:

AutoRoute(path: '/:itemId', page: ItemDetailPage, fullMatch: true),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BambinoUA