I have generated routing using the auth_route (5.0.1) package in my project:
import 'package:auto_route/annotations.dart';
...
part 'app_router.gr.dart';
@MaterialAutoRouter(
replaceInRouteName: 'Page,Route',
routes: <AutoRoute>[
AutoRoute(page: AuthPage, initial: true),
AutoRoute(page: TutorialPage),
AutoRoute(page: LoginPage),
AutoRoute(page: SmsVerificationPage),
],
)
class AppRouter extends _$AppRouter {}
The part-of file app_router.gr.dart
generated successfully.
The problem is that the AppRouter
class was not generated with the delegate()
and defaultRouteParser()
functions.
What is the problem? Anyone else is also facing the same issue?
It seems that everything works just fine when the AppRouter is generated without a part-of file.
According to the official Setup, you can generate the file as part-of or not.
Apparently there is a sever difference between the two generated files:
I have opened an issue to auth_route
on Github. Feel free to follow and contribute!
i had same problem (flutter version 3.3.4 and auto_route v 5.0.1). my problem solved by importing auto_route to app_router.dart file (not generated file):
import 'package:auto_route/auto_route.dart';
app_router.dart file:
import 'package:auto_route/annotations.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
part 'app_router.gr.dart';
@MaterialAutoRouter(
replaceInRouteName: 'Screen,Route',
routes: <AutoRoute>[
...
],
)
// extend the generated private router
class AppRouter extends _$AppRouter{}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With