Skip to content

Commit

Permalink
Don't render not-found page during initial setup (flutter#6724)
Browse files Browse the repository at this point in the history
The router is always called with a `null` page when the app first loads. Previously this would render a not-found page and because there are also no args, it would be marked as not-embedded and would register with the server as a page that can be reused which (partly) caused Dart-Code/Dart-Code#4832.
  • Loading branch information
DanTup authored Nov 14, 2023
1 parent 3fb237d commit f0c533a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/devtools_app/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ class DevToolsAppState extends State<DevToolsApp> with AutoDisposeMixin {
Map<String, String?> args,
DevToolsNavigationState? state,
) {
if (FrameworkCore.initializationInProgress) {
// `page` will initially be null while the router is set up, then we will
// be called again with an empty string for the root.
if (FrameworkCore.initializationInProgress || page == null) {
return const MaterialPage(child: CenteredCircularProgressIndicator());
}

// Provide the appropriate page route.
if (pages.containsKey(page)) {
Widget widget = pages[page!]!(
Widget widget = pages[page]!(
context,
page,
args,
Expand Down Expand Up @@ -367,6 +369,9 @@ class DevToolsAppState extends State<DevToolsApp> with AutoDisposeMixin {
}

Map<String, UrlParametersBuilder> get _standaloneScreens {
// TODO(dantup): Standalone screens do not use DevToolsScaffold which means
// they do not currently send an initial "currentPage" event to inform
// the server which page they are rendering.
return {
for (final type in StandaloneScreenType.values)
type.name: (_, __, args, ___) => type.screen,
Expand Down

0 comments on commit f0c533a

Please sign in to comment.