0

Setting up a flutter project my app_router.dart file contains

@AutoRouterConfig(replaceInRouteName: 'Screen,Route')
class AppRouter extends $AppRouter {
 @override
 List<AutoRoute> get routes => <AutoRoute>[
 AutoRoute(page: DiscoverRoute.page, initial: true),
 ];
}

But $AppRouter is still red underlined after running dart run build_runner build --delete-conflicting-outputs

I have done the steps VS Code: Ctrl+Shift+P → "Dart: Restart Analysis Server"

Error below: lib/app/router/app_router.dart:18:25: Error: Type '$AppRouter' not found. class AppRouter extends $AppRouter { ^^^^^^^^^^ lib/main.dart:22:33: Error: The method 'delegate' isn't defined for the type 'AppRouter'.

  • 'AppRouter' is from 'package:sumo/app/router/app_router.dart' ('lib/app/router/app_router.dart'). Try correcting the name to the name of an existing method, or defining a method named 'delegate'. routerDelegate: appRouter.delegate(), ^^^^^^^^ lib/main.dart:23:41: Error: The method 'defaultRouteParser' isn't defined for the type 'AppRouter'.
  • 'AppRouter' is from 'package:sumo/app/router/app_router.dart' ('lib/app/router/app_router.dart'). Try correcting the name to the name of an existing method, or defining a method named 'defaultRouteParser'. routeInformationParser: appRouter.defaultRouteParser(),
asked Nov 1, 2025 at 17:38
1
  • Have you tried to remove "$" symbol from extends $AppRouter {...}? Commented Nov 1, 2025 at 19:13

1 Answer 1

2

Because auto_route migrated to a new syntax.

@AutoRouterConfig()
class AppRouter extends RootStackRouter {
 AppRouter() : super(); 
 
@override
 List<AutoRoute> get routes {
 return ...
 }
}

Find the doc: https://pub.dev/packages/auto_route#setup-and-usage

answered Nov 2, 2025 at 12:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.