[go_router] can't go same sub route Immediately

This issue has been tracked since 2022-11-25.

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Tap GridView Item and Go Item's Detail Page
  3. Pop Detail Page and Go Same Item's Detail Page

Expected results: I go 2's detail page -> pop -> go 2's detail page

Actual results: I go 2's detail page -> pop -> can't go 2's detail page

KakaoTalk_Video_2022-11-25-15-44-10.mp4
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});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: GoRouter(initialLocation: '/grid', routes: [
        GoRoute(
            name: 'Grid',
            path: '/grid',
            builder: (context, state) {
              return const GridPage();
            },
            routes: [
              GoRoute(
                name: 'Grid-Detail',
                path: ':id',
                builder: (context, state) {
                  return DetailPage(id: state.params['id'] as String);
                },
              ),
            ]),
      ]),
    );
  }
}

class GridPage extends StatefulWidget {
  const GridPage({super.key});

  @override
  State<GridPage> createState() => _GridPageState();
}

class _GridPageState extends State<GridPage> {
  late final ScrollController scrollController;

  @override
  void initState() {
    super.initState();
    scrollController = ScrollController();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        controller: scrollController,
        slivers: [
          SliverGrid(
            delegate: SliverChildBuilderDelegate(
                (context, index) => GestureDetector(
                      onTap: () {
                        context.go('/grid/$index');
                      },
                      child: Container(
                        color: Color.fromRGBO((index * 25) % 255,
                            (index * 47) % 255, index * 56 % 255, 1.0),
                        child: Center(child: Text(index.toString()),),
                      ),
                    ),
                childCount: 20),
            gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              mainAxisSpacing: 40,
              crossAxisSpacing: 4,
            ),
          )
        ],
      ),
    );
  }
}

class DetailPage extends StatelessWidget {
  const DetailPage({Key? key, required this.id}) : super(key: key);

  final String id;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          color: Colors.green,
          child: Center(
            child: Text(id.toString()),
          ),
        ),
      ),
    );
  }
}
Logs
flutter analyze
Analyzing sliver_persistent_header_ensure_visible_bug...                
No issues found! (ran in 1.4s)
 flutter doctor -v
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0 22A380 darwin-arm, locale ko-KR)
    • Flutter version 3.3.8 on channel stable at /Users/adforus/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 52b3dc25f6 (2 weeks ago), 2022-11-09 12:09:26 +0800
    • Engine revision 857bd6b74c
    • Dart version 2.18.4
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/adforus/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Users/adforus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/adforus/Downloads/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/adforus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Android Studio (version 2021.3)
    • Android Studio at /Users/adforus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
    • IntelliJ at /Users/adforus/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 71.0.5
    • Dart plugin version 222.4345.14

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.2)
    • IntelliJ at /Users/adforus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/222.4167.29/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.3)
    • IntelliJ at /Users/adforus/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/222.4345.14/IntelliJ IDEA.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.59.1)
    • VS Code at /Users/adforus/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.27.0

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • 29281FDH200DQD • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos          • darwin-arm64   • macOS 13.0 22A380 darwin-arm
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 107.0.5304.121

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

ValentinVignal wrote this answer on 2022-11-25

Maybe it is a duplicate of #115832

jpoh281 wrote this answer on 2022-11-25

@ValentinVignal
Yes. Duplicated.
May I close this Issue?

ValentinVignal wrote this answer on 2022-11-25

@jpoh281 Maybe you can let the flutter team close it as a duplicate

huycozy wrote this answer on 2022-11-25

Hi @jpoh281
This issue is reproducible with go_router: 5.2.0 whilst it works normally with go_router: 5.1.10. This is a known issue being tracked at #115832 as @ValentinVignal mentioned above. (Thank @ValentinVignal for mentioning reference issue)

Closing this issue as a duplicate, so please follow up on it for further updates. Thanks!

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2022-12-07
Star Count 147031
Watcher Count 3560
Fork Count 23915
Issue Count 11300

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date