-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[go_router] TypedGoRoute seems to be incompatible with PopScope #147959
Comments
Not work. Code sampleCode sample// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'main.dart';
// **************************************************************************
// GoRouterGenerator
// **************************************************************************
List<RouteBase> get $appRoutes => [
$firstRoute,
];
RouteBase get $firstRoute => GoRouteData.$route(
path: '/',
factory: $FirstRouteExtension._fromState,
routes: [
GoRouteData.$route(
path: 'second',
factory: $SecondRouteExtension._fromState,
),
],
);
extension $FirstRouteExtension on FirstRoute {
static FirstRoute _fromState(GoRouterState state) => FirstRoute();
String get location => GoRouteData.$location(
'/',
);
void go(BuildContext context) => context.go(location);
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
extension $SecondRouteExtension on SecondRoute {
static SecondRoute _fromState(GoRouterState state) => SecondRoute();
String get location => GoRouteData.$location(
'/second',
);
void go(BuildContext context) => context.go(location);
Future<T?> push<T>(BuildContext context) => context.push<T>(location);
void pushReplacement(BuildContext context) =>
context.pushReplacement(location);
void replace(BuildContext context) => context.replace(location);
}
Screenshots or VideoLogsLogs✓ Built build/app/outputs/flutter-apk/app-debug.apk
Installing build/app/outputs/flutter-apk/app-debug.apk...
Debug service listening on ws://127.0.0.1:56864/kfjjCSnrOrs=/ws
Syncing files to device sdk gphone64 arm64...
W/WindowOnBackDispatcher( 4751): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 4751): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/EGL_emulation( 4751): app_time_stats: avg=2597.12ms min=4.49ms max=5189.76ms count=2
D/EGL_emulation( 4751): app_time_stats: avg=73.52ms min=0.97ms max=915.95ms count=13
E/flutter ( 4751): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 5350 pos 12: '!_debugLocked': is not true.
E/flutter ( 4751): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:50:61)
E/flutter ( 4751): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter ( 4751): #2 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5350:12)
E/flutter ( 4751): #3 GoRouterDelegate.pop (package:go_router/src/delegate.dart:115:11)
E/flutter ( 4751): #4 GoRouter.pop (package:go_router/src/router.dart:490:20)
E/flutter ( 4751): #5 GoRouterHelper.pop (package:go_router/src/misc/extensions.dart:71:65)
E/flutter ( 4751): #6 SecondPage.build.<anonymous closure> (package:untitled4/main.dart:50:17)
E/flutter ( 4751): #7 PopScope._callPopInvoked (package:flutter/src/widgets/pop_scope.dart:140:19)
E/flutter ( 4751): #8 _PopScopeState.onPopInvokedWithResult (package:flutter/src/widgets/pop_scope.dart:172:12)
E/flutter ( 4751): #9 ModalRoute.onPopInvokedWithResult (package:flutter/src/widgets/routes.dart:1741:16)
E/flutter ( 4751): #10 NavigatorState.pop (package:flutter/src/widgets/navigator.dart:5362:19)
E/flutter ( 4751): #11 GoRouterDelegate.pop (package:go_router/src/delegate.dart:115:11)
E/flutter ( 4751): #12 GoRouter.pop (package:go_router/src/router.dart:490:20)
E/flutter ( 4751): #13 GoRouterHelper.pop (package:go_router/src/misc/extensions.dart:71:65)
E/flutter ( 4751): #14 SecondPage.build.<anonymous closure> (package:untitled4/main.dart:50:17)
E/flutter ( 4751): #15 PopScope._callPopInvoked (package:flutter/src/widgets/pop_scope.dart:140:19)
E/flutter ( 4751): #16 _PopScopeState.onPopInvokedWithResult (package:flutter/src/widgets/pop_scope.dart:172:12)
E/flutter ( 4751): #17 ModalRoute.onPopInvokedWithResult (package:flutter/src/widgets/routes.dart:1741:16)
E/flutter ( 4751): #18 NavigatorState.maybePop (package:flutter/src/widgets/navigator.dart:5319:25)
E/flutter ( 4751): <asynchronous suspension>
E/flutter ( 4751):
W/WindowOnBackDispatcher( 4751): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 4751): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
======== Exception caught by widgets library =======================================================
The following GoError was thrown building HeroControllerScope:
There is nothing to pop
The relevant error-causing widget was:
MaterialApp MaterialApp:file:///Users/chien/Flutter/untitled4/lib/main.dart:6:35
When the exception was thrown, this was the stack:
#0 GoRouterDelegate.pop (package:go_router/src/delegate.dart:113:7)
#1 GoRouter.pop (package:go_router/src/router.dart:490:20)
#2 GoRouterHelper.pop (package:go_router/src/misc/extensions.dart:71:65)
#3 SecondPage.build.<anonymous closure> (package:untitled4/main.dart:50:17)
#4 PopScope._callPopInvoked (package:flutter/src/widgets/pop_scope.dart:140:19)
#5 _PopScopeState.onPopInvokedWithResult (package:flutter/src/widgets/pop_scope.dart:172:12)
#6 ModalRoute.onPopInvokedWithResult (package:flutter/src/widgets/routes.dart:1741:16)
#7 _RouteEntry.handlePop (package:flutter/src/widgets/navigator.dart:3171:11)
#8 NavigatorState._flushHistoryUpdates (package:flutter/src/widgets/navigator.dart:4340:22)
#9 NavigatorState._updatePages (package:flutter/src/widgets/navigator.dart:4270:5)
#10 NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:3911:7)
#11 StatefulElement.update (package:flutter/src/widgets/framework.dart:5653:55)
#12 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#13 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#14 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#15 ProxyElement.update (package:flutter/src/widgets/framework.dart:5810:5)
#16 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#17 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#18 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#19 ProxyElement.update (package:flutter/src/widgets/framework.dart:5810:5)
#20 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:105:11)
#21 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#23 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5644:11)
#24 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#25 StatefulElement.update (package:flutter/src/widgets/framework.dart:5667:5)
#26 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#27 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#28 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#29 ProxyElement.update (package:flutter/src/widgets/framework.dart:5810:5)
#30 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#31 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#32 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#33 StatelessElement.update (package:flutter/src/widgets/framework.dart:5557:5)
#34 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#35 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#36 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#37 ProxyElement.update (package:flutter/src/widgets/framework.dart:5810:5)
#38 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#39 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#40 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#41 ProxyElement.update (package:flutter/src/widgets/framework.dart:5810:5)
#42 Element.updateChild (package:flutter/src/widgets/framework.dart:3821:15)
#43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5506:16)
#44 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5644:11)
#45 Element.rebuild (package:flutter/src/widgets/framework.dart:5197:7)
#46 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2905:19)
#47 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1136:21)
#48 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:468:5)
#49 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1392:15)
#50 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1313:9)
#51 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1171:5)
#52 _invoke (dart:ui/hooks.dart:312:13)
#53 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
#54 _drawFrame (dart:ui/hooks.dart:283:31)
====================================================================================================
Application finished. |
Thanks for the update. I was able to replicate using details provided. Looking at the error log, it may be similar / duplicate of other existing issues but use case is different so will keep this issue open. stable, master flutter doctor -v
|
in your PopScope, do this: |
go_router: ^14.0.2
go_router_builder: ^2.6.2
Steps to reproduce
Related issue: #119677 #137545 #138737
Expected results
Back to the first page without exception.
Actual results
Throw “Null check operator used on a null value”.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: