Search code examples
flutterdartflutter-web

Why do I get white screen when building flutter web


I want to build a flutter web app, so I enter 'webdev build' command and after the operation finishes, I open the 'index.html' file located in build directory and it's just a white screen. I tried it on a fresh project and the problem persists. There's no problem during developing.

enter image description here

Here's my flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17134.766], locale en-US)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.3)
[√] VS Code (version 1.35.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Solution

  • You need to run webdev serve command, it'll provide an address like localhost:8080 or 127.0.0.1:8080. I've attached a screenshot after running webdev serve for one of my Flutter Web Project. It says Serving web on http://127.0.0.1:8080 So you need to open that URL in Browser.

    enter image description here


    This answer was written when flutter-web was a separate project and webdev was the way to go for running your app.

    Now you can use flutter run -d chrome to run it for Web.