Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

ShellRoute deeplink not working if it's path isn't '/' #8

@pierremrtn

Description

@pierremrtn

Hello,

I think I've encountered a bug with ShellRoute. Considering the following router setup, I'm not able to navigate to /shell/child when entering url in navigator (chrome):

  final GoRouter _router = GoRouter(
    routes: [
      StackedRoute(
        path: '/',
        builder: (context) => const DummyPage(),
      ),
      ShellRoute(
        path: '/shell',
        builder: (context, child) => Scaffold(
          body: child,
          appBar: AppBar(title: const Text('Shell')),
        ),
        routes: [
          StackedRoute(
            path: 'child',
            builder: (context) => const DummyPage(),
          ),
        ],
      ),
      StackedRoute(
        path: '/other',
        builder: (context) => const DummyPage(),
      ),
    ],
  );

I'm able to navigate to /, /shell, and /other, but when I'm entering /shell/child in the url I'm redirected to /.
The problem disappears if I set the ShellRoute path to / instead of /shell.

Here is a minimal reproducible example.

import 'package:flutter/material.dart';
import 'package:go_router_prototype/go_router_prototype.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(App());
}

class App extends StatelessWidget {
  App({
    super.key,
  });

  final GoRouter _router = GoRouter(
    routes: [
      StackedRoute(
        path: '/',
        builder: (context) => const DummyPage(),
      ),
      ShellRoute(
        path: '/shell',
        builder: (context, child) => Scaffold(
          body: child,
          appBar: AppBar(title: const Text('Shell')),
        ),
        routes: [
          StackedRoute(
            path: 'child',
            builder: (context) => const DummyPage(),
          ),
        ],
      ),
      StackedRoute(
        path: '/other',
        builder: (context) => const DummyPage(),
      ),
    ],
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routeInformationParser: _router.parser,
      routerDelegate: _router.delegate,
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(RouteState.of(context).route.path),
    );
  }
}

I hope I'm not disrupting this project by opening this issue since it's only a prototype.
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions