I've entered for the first time into Flutter on an already going on a project. This project was using the auto_route plugin already, with multiple pages.
As a task, I needed to update the version of the plugin to the last one (now 7.7.1)
I used the plugin on Android Studio suggested by them, AutoRoute-helper, to change the majority of the things.
I fixed one or two other things, but there is one I cannot fix:
AutoRoute(path: '/auth/', page: Auth.page, meta: {'name': 'Authentication'}),
In the Router file.
But I'm receiving the error: The getter 'page' isn't defined for the type 'Auth'.
Inside the page authentication.dart (imported inside router):
...
import 'package:auto_route/auto_route.dart';
...
@RoutePage()
class Auth extends StatefulWidget {
final int? eventRedirectId;
final VoidCallback? onAuthenticationComplete;
const Auth({
Key? key,
this.onAuthenticationComplete,
this.eventRedirectId
}) : super(key: key);
@override
AuthState createState() => AuthState();
}
...
I launched the command flutter packages pub run build_runner build but still my router doesn't recognize the .name
I couldn't find any documentation or tutorial that does something different from what i did, does somebody have any idea on what could be the problem?
I tried to follow step by-step any tutorial I could find on how to create a new project with auto_route, doing the exact same things. I don't understand what i could miss, and where the name comes from, everybody just seems to add @RoutePage(), build, and then they can use the name property.
---------------------------UPDATE
The problem i had is that classes are imported not from the page directly, but from the router.gr.dart file. By default, generated classes there have the suffix Route, so my class was not Auth, but AuthRoute.
Using AuthRoute.name solved the issue.