-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#6920Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14has 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
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Use go_router 10
- Run the code sample on chrome or simulator
- Observe the console output
It used to work with go_router 8.x.x when I was able to get the router location by using GoRouter.of(context).location.
Expected results
Able to get go router state within the routes of a nested Navigator.
Actual results
Assertion was thrown.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
final router = GoRouter(routes: [
GoRoute(
path: '/',
builder: (BuildContext context, GoRouterState state) => const MyHomePage(),
),
]);
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(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
routerConfig: router,
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Navigator(
pages: const [
MaterialPage(
child: MySubPage(),
),
],
onPopPage: (route, result) {
if (!route.didPop(result)) {
return false;
}
return true;
},
),
);
}
}
class MySubPage extends StatelessWidget {
const MySubPage({super.key});
@override
Widget build(BuildContext context) {
final fullPath = GoRouterState.of(context).fullPath ?? '';
return Center(
child: Text(fullPath),
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY
╞═══════════════════════════════════════════════════════════
The following assertion was thrown building MySubPage(dirty,
dependencies:
[GoRouterStateRegistryScope, _ModalScopeStatus]):
'package:go_router/src/state.dart': Failed assertion: line 204 pos
12: 'registry.containsKey(page)':
is not true.
The relevant error-causing widget was:
MySubPage
MySubPage:file:///Users/CrizantLai/Documents/go_router_test/lib/
main.dart:42:20
When the exception was thrown, this was the stack:
#2 GoRouterStateRegistry._createPageRouteAssociation
(package:go_router/src/state.dart:204:12)
#3 GoRouterState.of (package:go_router/src/state.dart:126:25)
#4 MySubPage.build (package:go_router_test/main.dart:61:36)
#5 StatelessElement.build
(package:flutter/src/widgets/framework.dart:5156:49)
#6 ComponentElement.performRebuild
(package:flutter/src/widgets/framework.dart:5086:15)
#7 Element.rebuild
(package:flutter/src/widgets/framework.dart:4805:7)
#8 ComponentElement._firstBuild
(package:flutter/src/widgets/framework.dart:5068:5)
#9 ComponentElement.mount
(package:flutter/src/widgets/framework.dart:5062:5)
... Normal element mounting (24 frames)
#33 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#34 MultiChildRenderObjectElement.inflateWidget
(package:flutter/src/widgets/framework.dart:6570:36)
#35 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6582:32)
... Normal element mounting (178 frames)
#213 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#214 MultiChildRenderObjectElement.inflateWidget
(package:flutter/src/widgets/framework.dart:6570:36)
#215 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6582:32)
... Normal element mounting (95 frames)
#310 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#311 MultiChildRenderObjectElement.inflateWidget
(package:flutter/src/widgets/framework.dart:6570:36)
#312 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6582:32)
... Normal element mounting (140 frames)
#452 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#453 MultiChildRenderObjectElement.inflateWidget
(package:flutter/src/widgets/framework.dart:6570:36)
#454 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6582:32)
... Normal element mounting (178 frames)
#632 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#633 MultiChildRenderObjectElement.inflateWidget
(package:flutter/src/widgets/framework.dart:6570:36)
#634 MultiChildRenderObjectElement.mount
(package:flutter/src/widgets/framework.dart:6582:32)
... Normal element mounting (525 frames)
#1159 Element.inflateWidget
(package:flutter/src/widgets/framework.dart:3971:16)
#1160 Element.updateChild
(package:flutter/src/widgets/framework.dart:3708:18)
#1161 RenderObjectToWidgetElement._rebuild
(package:flutter/src/widgets/binding.dart:1240:16)
#1162 RenderObjectToWidgetElement.mount
(package:flutter/src/widgets/binding.dart:1209:5)
#1163 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous
closure> (package:flutter/src/widgets/binding.dart:1156:18)
#1164 BuildOwner.buildScope
(package:flutter/src/widgets/framework.dart:2720:19)
#1165 RenderObjectToWidgetAdapter.attachToRenderTree
(package:flutter/src/widgets/binding.dart:1155:13)
#1166 WidgetsBinding.attachRootWidget
(package:flutter/src/widgets/binding.dart:988:7)
#1167 WidgetsBinding.scheduleAttachRootWidget.<anonymous
closure> (package:flutter/src/widgets/binding.dart:968:7)
#1171 _RawReceivePort._handleMessage
(dart:isolate-patch/isolate_patch.dart:189:12)
(elided 5 frames from class _AssertionError, class _Timer, and
dart:async-patch)
══════════════════════════════════════════════════════════════════
══════════════════════════════════Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d
darwin-x64, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK
version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.81.1)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!davidhicks980, ReversedHourglass, ja2375 and SunlightBro
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14has 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