-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#3613Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has 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.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
It started to reproduce in the 6.5.0 version of go_router, 6.4.1 works as expected.
Steps to Reproduce
- Make sure that you have
flutter: 3.7.8and that you addedgo_router: 6.5.0as a dependency. - Use the code sample provided below
- Run the app
- Press the "Open Settings" button
- Press the "Show" button in the Settings screen, and a dialog will appear
- Press the "Pop" button, and a dialog will close
- Press the "Show" button on the Settings screen, and a dialog will appear again
- Press the "Pop" button, and an error will be thrown (Bad state: Future already completed)
Expected results:
The dialog should be popped without error.
Actual results:
The dialog popped with the error: Bad state: Future already completed.
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
final _router = GoRouter(
debugLogDiagnostics: true,
routes: [
GoRoute(
path: '/',
builder: (context, state) => const Home(),
),
GoRoute(
path: '/settings',
builder: (context, state) => const Settings(),
),
],
);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
debugShowCheckedModeBanner: false,
);
}
}
class Home extends StatefulWidget {
const Home({super.key});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: TextButton(
onPressed: () {
context.push('/settings');
},
child: const Text('Open Settings'),
),
),
],
),
);
}
}
class Settings extends StatelessWidget {
const Settings({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: [
TextButton(
onPressed: () {
context.pop();
},
child: const Text('Back'),
)
],
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: TextButton(
onPressed: () {
showMyDialog(context);
},
child: const Text('Show'),
),
),
],
),
);
}
}
void showMyDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return Center(
child: Container(
width: 100,
height: 200,
color: Colors.red,
child: Column(
children: [
TextButton(
onPressed: () {
context.pop();
},
child: const Text('Pop'),
),
],
),
),
);
},
);
}
Logs
══╡ EXCEPTION CAUGHT BY GESTURE
╞═══════════════════════════════════════════════════════════════════
The following StateError was thrown while handling a gesture:
Bad state: Future already completed
When the exception was thrown, this was the stack:
#1 ImperativeRouteMatch.complete (package:go_router/src/delegate.dart:334:16)
#2 GoRouterDelegate.pop (package:go_router/src/delegate.dart:133:33)
#3 GoRouter.pop (package:go_router/src/router.dart:347:21)
#4 GoRouterHelper.pop (package:go_router/src/misc/extensions.dart:69:65)
#5 showMyDialog.<anonymous closure>.<anonymous closure>
(package:example/main.dart:113:27)
#6 _InkResponseState.handleTap
(package:flutter/src/material/ink_well.dart:1096:21)
#7 GestureRecognizer.invokeCallback
(package:flutter/src/gestures/recognizer.dart:253:24)
#8 TapGestureRecognizer.handleTapUp
(package:flutter/src/gestures/tap.dart:627:11)
#9 BaseTapGestureRecognizer._checkUp
(package:flutter/src/gestures/tap.dart:306:5)
#10 BaseTapGestureRecognizer.handlePrimaryPointer
(package:flutter/src/gestures/tap.dart:239:7)
#11 PrimaryPointerGestureRecognizer.handleEvent
(package:flutter/src/gestures/recognizer.dart:615:9)
#12 PointerRouter._dispatch
(package:flutter/src/gestures/pointer_router.dart:98:12)
#13 PointerRouter._dispatchEventToRoutes.<anonymous closure>
(package:flutter/src/gestures/pointer_router.dart:143:9)
#14 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:625:13)
#15 PointerRouter._dispatchEventToRoutes
(package:flutter/src/gestures/pointer_router.dart:141:18)
#16 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
#17 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:460:19)
#18 GestureBinding.dispatchEvent
(package:flutter/src/gestures/binding.dart:440:22)
#19 RendererBinding.dispatchEvent
(package:flutter/src/rendering/binding.dart:336:11)
#20 GestureBinding._handlePointerEventImmediately
(package:flutter/src/gestures/binding.dart:395:7)
#21 GestureBinding.handlePointerEvent
(package:flutter/src/gestures/binding.dart:357:5)
#22 GestureBinding._flushPointerEventQueue
(package:flutter/src/gestures/binding.dart:314:7)
#23 GestureBinding._handlePointerDataPacket
(package:flutter/src/gestures/binding.dart:295:7)
#24 _invoke1 (dart:ui/hooks.dart:164:13)
#25 PlatformDispatcher._dispatchPointerDataPacket
(dart:ui/platform_dispatcher.dart:361:7)
#26 _dispatchPointerDataPacket (dart:ui/hooks.dart:91:31)
(elided one frame from dart:async)
Handler: "onTap"
Recognizer:
TapGestureRecognizer#7e3fe
════════════════════════════════════════════════════════════════════════════════════════════════════
Analyzing example...
No issues found! (ran in 0.7s)
[✓] Flutter (Channel stable, 3.7.8, on macOS 13.2.1 22D68 darwin-arm64, locale en-US)
• Flutter version 3.7.8 on channel stable at /Users/eli1stark/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 90c64ed42b (2 days ago), 2023-03-21 11:27:08 -0500
• Engine revision 9aa7816315
• Dart version 2.19.5
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/eli1stark/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: /Applications/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.12.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• 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.13+0-b1751.21-8125866)
[✓] VS Code (version 1.76.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.60.0
[✓] Connected device (3 available)
• iPhone 14 Pro Max (mobile) • 06D4130A-8626-4B40-82DA-F463E0719F26 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.2.1
22D68 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome
111.0.5563.110
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
HaloWang, gggitpl, KabaDH, ValeriusGC, nsvetlakov and 12 moreHaloWang, ClaudeChey, gggitpl, BBarisKilic, DattatreyaReddy and 2 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowfound in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has 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.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version