Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.58k stars 402 forks source link

Inherited params not working #1888

Closed PhuCG closed 7 months ago

PhuCG commented 7 months ago

Hello ! I have recreated the demo with Inherited params use case but it doesn't seem to work here is how I implemented it, what did I do wrong? Router config:

import 'package:auto_route/auto_route.dart';
import 'package:inherited_params_issues/router.gr.dart';

@AutoRouterConfig()
class RootRouter extends $RootRouter {
  @override
  final List<AutoRoute> routes = [
    AutoRoute(path: '/', page: HomeRoute.page),
    AutoRoute(
      page: BooksTab.page,
      children: [
        RedirectRoute(path: '', redirectTo: 'books'),
        AutoRoute(
          path: 'books',
          page: BookListRoute.page,
        ),
        AutoRoute(
          path: 'book/:id',
          page: BookDetailsRoute.page,
          children: [
            AutoRoute(path: 'review', page: ReviewRoute.page),
          ],
        ),
      ],
      title: (ctx, _) => 'Books list',
    ),
  ];
}

@RoutePage(name: 'BooksTab')
class BooksTabPage extends AutoRouter {
  const BooksTabPage({super.key});
}

My flow HomePage -> ListBook -> BookDetail -> BookReview and this is log when i try to review page context.pushRoute(ReviewRoute());

Screenshot 2024-03-13 at 21 22 50 I have built a small source code to reproduce you can take a look: https://github.com/PhuCG/ParamInheritanceIssues pls help, thank alot.

ENV Flutter 3.19.3 auto_route 7.9.0 build_runner: ^2.4.8

Milad-Akarie commented 7 months ago

Hey @PhuCG in your example BookDetailsRoute should be a parent route but BookDetailsPage does not have an AutoRouter widget inside it to render child routes. please refer to this https://pub.dev/packages/auto_route#nested-navigation