Skip to content

[go_router] ShellRoute sub routes not shown in debugLogDiagnostics log #113819

@Skogsfrae

Description

@Skogsfrae

The log printed when debugLogDiagnostics flag is set to true ignores every sub route declared inside a ShellRoute.

Steps to Reproduce

Run the Code Sample with flutter run

Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: router,
    );
  }
}

final router = GoRouter(
  debugLogDiagnostics: true,
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => Center(
        child: Text('home'),
      ),
      routes: [
        GoRoute(
          path: 'inner-path-1',
          builder: (context, state) => Text('Hello'),
        ),
        ShellRoute(
          builder: (context, state, child) => Center(
            child: child,
          ),
          routes: [
            GoRoute(
              path: 'shell-route-path-1',
              builder: (context, state) => Text('Hello'),
            ),
            GoRoute(
              path: 'shell-route-path-2',
              builder: (context, state) => Text('World'),
            ),
          ],
        )
      ],
    ),
  ],
);
Logs

Actual log

[GoRouter] Full paths for routes:
             => /
             =>   /inner-path-1
[GoRouter] setting initial location null
[GoRouter] Using MaterialApp configuration

Expected log

[GoRouter] Full paths for routes:
             => /
             =>   /inner-path-1
             =>   /shell-route-path-1
             =>   /shell-route-path-2
[GoRouter] setting initial location null
[GoRouter] Using MaterialApp configuration

Expected results: ShellRoute sub paths should be explored as well to print that log.

I found the problem is in the _debugFullPathsFor function in lib/src/configuration.dart which ignores ShellRoutes not exploring them recursively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectfound in release: 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions