我一直收到这个错误(Android Studio)。
lib/routes/router.dart
:
import 'package:auto_route/auto_route.dart';
import 'package:salomon_routing_tutorial/home_page.dart';
...
@AdaptiveAutoRouter(
replaceInRouteName: 'Page,Route',
...
pubspec.yaml
:
name: salomon_routing_tutorial
description: Flutter Bottom Navigation with Nested Routing Tutorial.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.17.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
auto_route: ^6.0.5
salomon_bottom_bar: ^3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.4
auto_route_generator: ^6.0.3
build_runner: ^2.1.2
analyzer: ^5.10.0
flutter:
uses-material-design: true
打字错误应该是不可能的,有问题的名字是从一个正在工作的项目中复制的。可能是什么?
试试这个。。
-
删除router.dart和router.gr.dart(如果已创建)文件
-
创建一个文件app_router.dart并复制下面的代码。
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; part 'app_router.gr.dart'; @AutoRouterConfig(replaceInRouteName: 'Page,Route') class AppRouter extends _$AppRouter { @override RouteType get defaultRouteType => const RouteType.adaptive(); //.cupertino, .adaptive ..etc @override final List<AutoRoute> routes = [ //routes here ]; }
保存并运行build_runner