-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Open
flutter/packages
#10476Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.39Found to occur in 3.39Found to occur in 3.39frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamOwned by Framework team
Description
What package does this bug report belong to?
go_router
What target platforms are you seeing this bug on?
Android, iOS
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
version: "2.13.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
characters:
dependency: transitive
description:
name: characters
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.4.0"
clock:
dependency: transitive
description:
name: clock
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.19.1"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev"
source: hosted
version: "1.0.8"
fake_async:
dependency: transitive
description:
name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.3"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "3105dc8492f6183fb076ccf1f351ac3d60564bff92e20bfc4af9cc1651f4e7e1"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
go_router:
dependency: "direct main"
description:
name: go_router
sha256: c92d18e1fe994cb06d48aa786c46b142a5633067e8297cff6b5a3ac742620104
url: "https://pub.dev"
source: hosted
version: "17.0.0"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
lints:
dependency: transitive
description:
name: lints
sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0
url: "https://pub.dev"
source: hosted
version: "6.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
url: "https://pub.dev"
source: hosted
version: "1.3.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.17.0"
path:
dependency: transitive
description:
name: path
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
source_span:
dependency: transitive
description:
name: source_span
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
url: "https://pub.dev"
source: hosted
version: "1.10.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
url: "https://pub.dev"
source: hosted
version: "1.12.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43"
url: "https://pub.dev"
source: hosted
version: "1.4.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e"
url: "https://pub.dev"
source: hosted
version: "1.2.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.7"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.2.0"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
url: "https://pub.dev"
source: hosted
version: "15.0.2"
sdks:
dart: ">=3.10.0 <4.0.0"
flutter: ">=3.29.0"
Steps to reproduce
- Run the attached reproduction app.
- Click "Push Allowed" to navigate to /allowed. (Stack: ['/', '/allowed']).
- Perform a System Back Gesture (swipe back) OR click the AppBar Back Button.
- The app returns to / (Home).
- Click "Go to Blocked".
- onEnter intercepts the navigation to /blocked and returns Block.stop().
- The app mistakingly pushes Allowed and causes stack errors
Expected results
The app should stay on the home page when clicked "Go to Blocked"
Actual results
The app mistakingly pushes Allowed Page and causes stack errors
Code sample
Code sample
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(MaterialApp.router(routerConfig: _router, title: 'GoRouter Repro'));
}
final GoRouter _router = GoRouter(
onEnter: (context, state, next, router) {
if (next.uri.path == '/blocked') {
log('onEnter: Blocking navigation to /blocked');
return const Block.stop();
}
return const Allow();
},
routes: [
GoRoute(path: '/', builder: (context, state) => const HomePage()),
GoRoute(path: '/allowed', builder: (context, state) => const AllowedPage()),
GoRoute(
path: '/blocked',
builder: (context, state) =>
const Scaffold(body: Center(child: Text('Blocked'))),
),
],
);
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
log('HomePage build');
return Scaffold(
appBar: AppBar(title: const Text('Home')),
body: Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
log('Pushing /allowed');
context.push('/allowed');
},
child: const Text('1. Push Allowed'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
log('Going to /blocked');
context.go('/blocked');
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: const Text(
'3. Go to Blocked (You will go to Allowed Page but it should stay here)',
),
),
),
],
),
),
),
);
}
}
class AllowedPage extends StatelessWidget {
const AllowedPage({super.key});
@override
Widget build(BuildContext context) {
log('AllowedPage build');
return PopScope(
onPopInvokedWithResult: (didPop, result) {
log('onPopInvokedWithResult(AllowedPage): $didPop, $result');
},
child: Scaffold(
backgroundColor: Colors.red.shade100,
appBar: AppBar(
title: const Text('Allowed'),
// Default back button behaves same as system back gesture
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text.rich(
TextSpan(
children: [
TextSpan(
text:
'2. Go Back using System Gesture or AppBar Back Button (You will be on Home Page)',
),
TextSpan(
text:
'\n\nIf you use `context.pop()` The issue will not happen since it will update the `_lastMatchList` cache in the `GoRouteInformationParser`',
style: TextStyle(fontStyle: FontStyle.italic),
),
],
),
textAlign: TextAlign.center,
),
],
),
),
),
),
);
}
}
Screenshots or Videos
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[log] HomePage build
[log] Pushing /allowed
[log] AllowedPage build
[log] onPopInvokedWithResult(AllowedPage): true, null
[log] Going to /blocked
[log] onEnter: Blocking navigation to /blocked
[log] AllowedPage buildFlutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.38.1, on macOS 15.6.1 24G90 darwin-arm64, locale en-US) [682ms]
• Flutter version 3.38.1 on channel stable at /Users/arinfaraj/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b45fa18946 (7 days ago), 2025-11-12 22:09:06 -0600
• Engine revision b5990e5ccc
• Dart version 3.10.0
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.8s]
• Android SDK at /Users/arinfaraj/Library/Android/sdk
• Emulator version 35.3.11.0 (build_id 12836668) (CL:N/A)
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [1,159ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (4 available) [10.3s]
• CPH2649 (mobile) • 4a3e632c • android-arm64 • Android 16 (API 36)
• DIT iPhone 13 Pro (wireless) (mobile) • 00008110-000A61C234B9801E • ios • iOS 26.1 23B85
• macOS (desktop) • macos • darwin-arm64 • macOS 15.6.1 24G90 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 142.0.7444.176
! Error: Browsing on the local area network for Abdullah. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources [667ms]
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.found in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.39Found to occur in 3.39Found to occur in 3.39frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packageThe go_router packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamOwned by Framework team