Skip to content

[WEB] Losing url state after hot restart #79241

@ghost

Description

  1. Run my example app.
  2. Got to page two and hot reload.

Expected results: Current page reloads, as it used to.

Actual results: App reloads and takes you back to the initial route

import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp() : super(key: const ValueKey('MyApp'));

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      initialRoute: '/',
      routes: {
        '/': (context) => MyHomePage(),
        '/second': (context) => MySecondPage(),
      },
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
            child: Column(
          children: [
            Text('Home'),
            ElevatedButton(
              onPressed: () => Navigator.of(context).pushNamed('/second'),
              child: Text('Page 2'),
            )
          ],
        )),
      );
}

class MySecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(child: Text('Page 2')),
      );
}

Logs
PS C:\Users\kgcar\Desktop\test\test_proj> flutter run --verbose
[  +69 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +59 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 5bedb7b1d5698ce2c1c67aaf9afae7b3948b172a
[   +1 ms] executing: [C:\src\flutter/] git tag --points-at 5bedb7b1d5698ce2c1c67aaf9afae7b3948b172a
[  +51 ms] Exit code 0 from: git tag --points-at 5bedb7b1d5698ce2c1c67aaf9afae7b3948b172a
[   +1 ms] 2.1.0-12.2.pre
[  +45 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +39 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] origin/beta
[        ] executing: [C:\src\flutter/] git ls-remote --get-url origin
[  +32 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +67 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref HEAD
[  +34 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +1 ms] beta
[  +78 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +58 ms] executing: C:\Users\kgcar\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +43 ms] List of devices attached
[   +6 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +72 ms] Multiple devices found:
[  +22 ms] Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90
[   +1 ms] Edge (web)   • edge   • web-javascript • Microsoft Edge 89.0.774.63
[   +2 ms] [1]: Chrome (chrome)
[        ] [2]: Edge (edge)
[   +2 ms] Please choose one (To quit, press "q/Q")
[        ] : 
[+1130 ms] 1
[  +13 ms] Skipping pub get: version match.
[ +111 ms] Generating C:\Users\kgcar\Desktop\test\test_proj\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +80 ms] Launching lib\main.dart on Chrome in debug mode...
[ +103 ms] Updating assets
[  +69 ms] Waiting for connection from debug service on Chrome...
[ +103 ms] <- reset
[   +6 ms] C:\src\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev
C:\src\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root C:\src\flutter\bin\cache\flutter_web_sdk/ --incremental   
--target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill
C:\Users\kgcar\AppData\Local\Temp\flutter_tools.2573de6a\flutter_tool.11312f3e\app.dill --libraries-spec
file:///C:/src/flutter/bin/cache/flutter_web_sdk/libraries.json --packages C:\Users\kgcar\Desktop\test\test_proj\.dart_tool\package_config.json
-Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root
C:\Users\kgcar\AppData\Local\Temp\flutter_tools.2573de6a\flutter_tools.3a63aca4 --filesystem-scheme org-dartlang-app --initialize-from-dill
build\c7922d95bf4a2462b75c84a97c312edb.cache.dill.track.dill --platform file:///C:/src/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk.dill     
--no-sound-null-safety
[  +12 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+14225 ms] Waiting for connection from debug service on Chrome... (completed in 14.3s)
[   +2 ms] Synced 29.2MB.
[   +1 ms] <- accept
[   +1 ms] Caching compiled dill
[ +310 ms] Using Opening in existing browser session.

[+31163 ms] [CHROME]:
[   +3 ms] [CHROME]:DevTools listening on ws://127.0.0.1:54800/devtools/browser/470b9995-a18c-4e4f-9f67-f7d6048914b4
[+1243 ms] DwdsInjector: Received request for entrypoint at http://localhost:54646/main_module.bootstrap.js
[   +6 ms] MetadataProvider: Loading debug metadata...
[  +16 ms] MetadataProvider: Loaded debug metadata (no sound null safety)
[   +6 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:54646/main_module.bootstrap.js
[+5308 ms] ChromeProxyService: Initializing expression compiler for main_module.bootstrap.js with sound null safety: false
[ +468 ms] DevHandler: Debug service listening on ws://127.0.0.1:54837/Urq6VzL-JsE=/ws

[  +10 ms] Debug service listening on ws://127.0.0.1:54837/Urq6VzL-JsE=/ws
[        ] Running with unsound null safety
[        ] For more information see https://dart.dev/null-safety/unsound-null-safety
[   +3 ms]   To hot restart changes while running, press "r" or "R".
[        ] For a more detailed help message, press "h". To quit, press "q".
[+40143 ms] Performing hot restart...
[   +3 ms] Initializing file store
[   +9 ms] Skipping target: gen_localizations
[  +12 ms] complete
[  +49 ms] Scanned through 512 files in 48ms
[   +1 ms] Waiting for connection from debug service on Chrome...
[   +2 ms] <- recompile org-dartlang-app:/web_entrypoint.dart d5ee7922-97c8-476e-a038-465b57881ce3
[        ] <- d5ee7922-97c8-476e-a038-465b57881ce3
[  +11 ms] Waiting for connection from debug service on Chrome... (completed in 13ms)
[        ] Synced 0.0MB.
[        ] <- accept
[   +2 ms] DwdsVmClient: Attempting a hot restart
[        ] DwdsVmClient: Attempting to disabling breakpoints and resume the isolate
[   +7 ms] DwdsVmClient: Successfully disabled breakpoints and resumed the isolate
[        ] DwdsVmClient: Attempting to get execution context ID.
[        ] DwdsVmClient: Got execution context ID.
[        ] DwdsVmClient: Issuing $dartHotRestart request.
[  +67 ms] ChromeProxyService: Initializing expression compiler for main_module.bootstrap.js with sound null safety: false
[  +21 ms] DwdsVmClient: $dartHotRestart request complete.
[        ] DwdsVmClient: Waiting for Isolate Start event.
[   +2 ms] DwdsVmClient: Successful hot restart
[   +1 ms] Performing hot restart... (completed in 198ms)
[        ] Restarted application in 200ms.

[√] Flutter (Channel beta, 2.1.0-12.2.pre, on Microsoft Windows [Version 10.0.19042.870], locale en-GB)
    • Flutter version 2.1.0-12.2.pre at C:\src\flutter
    • Framework revision 5bedb7b1d5 (11 days ago), 2021-03-17 17:06:30 -0700
    • Engine revision 711ab3fda0
    • Dart version 2.13.0 (build 2.13.0-116.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\kgcar\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.54.3)
    • VS Code at C:\Users\kgcar\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.20.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.90
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 89.0.774.63

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowf: routesNavigator, Router, and related APIs.found in release: 2.1Found to occur in 2.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions