Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.55k stars 392 forks source link

Cannot navigate to child route with @PathParam.inherit("param"). #1963

Closed dipak-pd closed 3 weeks ago

dipak-pd commented 2 months ago

Getting error when trying to navigate to a nested route:

I/flutter ( 6896): Missing or invalid required parameter I/flutter ( 6896): Failed to parse [int] quotationId value from null I/flutter ( 6896): #0 Parameters.getInt (package:auto_route/src/common/parameters.dart:85:7) I/flutter ( 6896): #1 new $AppRouter.. (package:shilpkar/router/router.gr.dart:279:39) I/flutter ( 6896): #2 RouteData.argsAs (package:auto_route/src/route/route_data.dart:101:22) I/flutter ( 6896): #3 new $AppRouter. (package:shilpkar/router/router.gr.dart:277:30) I/flutter ( 6896): #4 RootStackRouter._pageBuilder (package:auto_route/src/router/controller/root_stack_router.dart:161:20) I/flutter ( 6896): #5 StackRouter._addEntry (package:auto_route/src/router/controller/routing_controller.dart:1570:29) I/flutter ( 6896): #6 StackRouter._push (package:auto_route/src/router/controller/routing_controller.dart:1275:14) I/flutter ( 6896):

This is route config

AutoRoute(
     page: DashboardQGRoute.page,
     path: "project-services/quotation-new/:quotationId",
     children: [
         AutoRoute(
         page: RoomSelectionRoute.page,
         path: "room-selection",
             ),
        ]),

DashboardQG screen

@RoutePage()
class DashboardQGScreen extends ConsumerWidget {
  const DashboardQGScreen({
    @PathParam('quotationId') required this.quotationId,
    super.key,
  });
  final int quotationId;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: const CommonAppBar(title: Text("data")),
      body: Center(
        child: IconButton(
          onPressed: () {
            context.router.push(RoomSelectionRoute());
          },
          icon: Icon(Icons.add),
        ),
      ),
    );
  }
}

RoomSelection Screen

@RoutePage()
class RoomSelectionScreen extends StatelessWidget {
  const RoomSelectionScreen(
      {super.key, @PathParam.inherit('quotationId') required int id});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const CommonAppBar(title: Text("Room selection")),
      body: Container(),
    );
  }
}
abhi259 commented 2 months ago

Facing this same issue

ghanasyam-n commented 2 months ago

I am also facing similar issue with AutoRoute.before it was working fine.

minkesh-pidilite commented 2 months ago

Facing the same issue, stuck for 2 days because of this. Please help.

dipak-pd commented 2 months ago

I don't understand what's wrong with this package, I can't even navigate to any nested route.

Configuration


@AutoRouterConfig(replaceInRouteName: 'Screen,Route')
class AppRouter extends $AppRouter {
  @override
  List<AutoRoute> get routes => <AutoRoute>[
        AutoRoute(
            page: Dashboard.page,
            path: '/dashboard',
            initial: true,
            children: [AutoRoute(page: ProjectRoute.page, path: 'project')])
      ];
}

Not able to navigate either push or pushNamed

context.router.push(ProjectRoute());

context.router.pushNamed('/dashboard/project');

Every time it's navigating to dashboard.

dipak-pd commented 2 months ago

1958 is similar issue

uvais-codes commented 2 months ago

Same issue here.

Mik77o commented 2 months ago

Nested navigation seems to be broken to some extent. When I use the tabbar and try to push further, it just doesn't work (latest Flutter, latest version of auto_route, Flutter web).

Mik77o commented 2 months ago

@dipak-pd I fixed issues with nested navigation when I used AutoRouter(). You can read about this in docs for this package (nested navigation section).

dipak-pd commented 2 months ago

@dipak-pd I fixed issues with nested navigation when I used AutoRouter(). You can read about this in docs for this package (nested navigation section).

@Mik77o Thanks, I'll try again

Milad-Akarie commented 2 months ago

@dipak-pd is there an AutoRouter widget inside DashboardQGRoute.page ?

dipak-pd commented 2 months ago

@dipak-pd is there an AutoRouter widget inside DashboardQGRoute.page ?

No, only flutter widgets are there inside DashboardQGRoute.page.

I also tried out with a new project, it doesn't even work there

You can check this : https://github.com/dipak-pd/auto-router-test

pfcstyle commented 2 months ago

Facing same problem.
v.7.9.2

bughoho commented 1 month ago

same problem

jakelaws1 commented 1 month ago

same problem as well

Milad-Akarie commented 1 month ago

To render child routes you need a nested AutoRouter Widget ( an outlet ) please read the docs more carefully https://pub.dev/packages/auto_route#nested-navigation

github-actions[bot] commented 3 weeks ago

Without further information, we are unable to resolve this issue. Please feel free to provide additional details or respond to any questions above, and we will be happy to reopen the case. Thank you for your contribution!