[go_router] 5.2.0 `push` doesn't update the URL anymore.

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

Steps to Reproduce

  1. Execute flutter run on the code sample (see "Code sample" section below)
  2. Click on the button "Settings" to push the settings page
  3. Notice the URL didn't change when using go_router 5.2.0

Expected results:

I expect the URL to change

Actual results:

The URL didn't change


The issue doesn't happen in the previous version (5.1.10) so I believe this was introduced in flutter/packages#2786

I don't know if this is related to #99112 (comment) which plans to remove imperative methods. But since I didn't see anything in the changelogs or documentation, I'm assuming this is a regression.

Code sample

Or you can checkout https://github.com/ValentinVignal/flutter_app_stable/tree/go-router/push-no-url-change

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

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

final router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => const Home(),
    ),
    GoRoute(
      path: '/settings',
      builder: (context, state) => const Settings(),
    ),
  ],
);

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            router.push('/settings');
          },
          child: const Text('Settings'),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Settings'),
      ),
    );
  }
}
Logs
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...             25.8s
This app is linked to the debug service: ws://127.0.0.1:51507/t8SpI7d7848=/ws
Debug service listening on ws://127.0.0.1:51507/t8SpI7d7848=/ws

πŸ’ͺ Running with sound null safety πŸ’ͺ

πŸ”₯  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".

An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:51507/t8SpI7d7848=
Flutter Web Bootstrap: Auto
The Flutter DevTools debugger and profiler on Chrome is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:51507/t8SpI7d7848=
Analyzing flutter_app_stable...                                         
No issues found! (ran in 4.1s)
[βœ“] Flutter (Channel stable, 3.3.8, on macOS 11.6.8 20G730 darwin-x64, locale en-GB)
    β€’ Flutter version 3.3.8 on channel stable at /Users/valentin/flutter/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 30.0.3)
    β€’ Android SDK at /usr/local/Caskroom/android-sdk/4333796
    β€’ Platform android-33, build-tools 30.0.3
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Build 13C100
    β€’ CocoaPods version 1.11.3

[βœ“] Chrome - develop for the web
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 2021.1)
    β€’ Android Studio at /Applications/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.11+0-b60-7590822)

[βœ“] VS Code (version 1.73.1)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.52.0

[βœ“] Connected device (2 available)
    β€’ macOS (desktop) β€’ macos  β€’ darwin-x64     β€’ macOS 11.6.8 20G730 darwin-x64
    β€’ Chrome (web)    β€’ chrome β€’ web-javascript β€’ Google Chrome 107.0.5304.110

[βœ“] HTTP Host Availability
    β€’ All required HTTP hosts are available

β€’ No issues found!
Videos
5.2.0 5.1.10
Screen.Recording.2022-11-24.at.10.20.44.AM.mov
Screen.Recording.2022-11-24.at.10.17.18.AM.mov
exaby73 wrote this answer on 2022-11-24

Triage report

I can reproduce this issue. I can also confirm that the URL does indeed change in 5.1.10 but not in 5.2.0. Labeling as regression

Code Sample (Same as OP)
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

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

final router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => const Home(),
    ),
    GoRoute(
      path: '/settings',
      builder: (context, state) => const Settings(),
    ),
  ],
);

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

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

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            router.push('/settings');
          },
          child: const Text('Settings'),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Settings'),
      ),
    );
  }
}
vinay416 wrote this answer on 2022-11-24

Yeah I'm facing the same issue when pushing the route URl is not updating. In mobile app using context.go going to the route but once I back to previous route then I can't longer go to same route again.

s9th wrote this answer on 2022-11-27

context.pop() also doesn't update URL. Maybe it's a consequence, maybe it's the same root cause.

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