Flutter web 需要刷新浏览器以反映热重启后的变化

Aiy*_*yox 8 flutter flutter-web

我正在开发一个颤振 Web 项目并在 chrome 上运行它。每次我进行更改并按 时r,我都会看到以下几行:

Performing a hot restart...                                               
(This is taking an unexpectedly long time.)       -
Run Code Online (Sandbox Code Playgroud)

然后应用程序将完全冻结,热重启将永远持续下去。然后我需要刷新 chrome 浏览器以查看更改。刷新浏览器后,终端给了我以下信息:

Performing hot restart...                                               
216,378ms (!)
Restarted application in 216,380ms.
Run Code Online (Sandbox Code Playgroud)

我正在使用 VS 代码。如果我通过 运行项目Run > Run Without Debugging,在文件保存时热重启,我仍然需要刷新浏览器。

我尝试通过在服务器上运行flutter run -d web-server,网页不再冻结,但仍需要刷新以显示更改。如果我使用flutter fun -d web-server --verbose.

[+6946 ms] Performing hot restart...
[  +61 ms] Scanned through 534 files in 59ms
[   +1 ms] Syncing files to device Web Server...
[   +1 ms] <- recompile org-dartlang-app:/web_entrypoint.dart f4f6967d-4b7d-4fa1-ba9a-58ae7c209d8f
[        ] <- f4f6967d-4b7d-4fa1-ba9a-58ae7c209d8f
[  +22 ms] Syncing files to device Web Server... (completed in 24ms)
[   +3 ms] Synced 0.0MB.
[   +3 ms] <- accept
[   +1 ms] Recompile complete. Page requires refresh.
[   +2 ms] Performing hot restart... (completed in 0.1s)
[   +1 ms] Restarted application in 100ms.
Run Code Online (Sandbox Code Playgroud)

该问题并未在项目开始时发生。我不确定是什么导致了这个问题。这是我的医生输出:

[?] Flutter (Channel beta, 1.18.0-11.1.pre, on Microsoft Windows [Version 10.0.18362.836], locale en-SG)

[?] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[?] Chrome - develop for the web
[?] Android Studio (version 3.6)
[!] IntelliJ IDEA Ultimate Edition (version 2019.2)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[?] VS Code (version 1.45.1)
[?] Connected device (2 available)

! Doctor found issues in 1 category.
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题。

Aiy*_*yox 2

我已经解决了这个问题,尽管我仍然不知道原因是什么。我用有效的初始代码替换了 main.dart 文件。然后我替换回我的代码,问题就消失了。