Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter web requires browser refreshing to reflect changes after hot restart

I am working on a flutter web project and runs it on chrome. Every time I make changes and press r, I will see the following lines:

Performing a hot restart...                                               
(This is taking an unexpectedly long time.)       -

The app will then freeze completely and the hot restart just takes forever. I then need to refresh the chrome browser to see the changes. After I refresh the browser, the terminal gives me the following:

Performing hot restart...                                               
216,378ms (!)
Restarted application in 216,380ms.

I am using VS Code. If I run the project via Run > Run Without Debugging, which alto hot restart upon file save, I still need to refresh the browser.

I have tried running on the server via flutter run -d web-server, the web page doesn't freeze anymore but still requires refresh to show changes. Here is the terminal output if I run with 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.

The issue didn't occur right at the beginning of the project. I am not sure what I have touched to cause this problem. Here is my doctor output:

[√] 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.

Please help me with this issue.

like image 423
Aiyox Avatar asked Jun 08 '20 14:06

Aiyox


1 Answers

I have solved the problem although I still don't know what's the cause. I replaced the main.dart file with the initial code which works. I then replaced back my code and the issue is gone.

like image 53
Aiyox Avatar answered Oct 04 '22 21:10

Aiyox