17

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.
Tirth Patel
  • 5,443
  • 3
  • 27
  • 39
Xoltawn
  • 1,445
  • 1
  • 11
  • 17

11 Answers11

9

For me seemed to have been a problem with antivirus and running flutter run -d chrome --release solved my problem.

5

You have to upload your files to the server and put them inside the root folder.

If you want to put them in other folder, you have to edit the "index.html" file to tell hem the folder.

For example: If you upload your files to "test" folder, you have to edit this line of "index.html":

<base href="/">

To

<base href="/test/">
4

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.

E_net4
  • 27,810
  • 13
  • 101
  • 139
Tirth Patel
  • 5,443
  • 3
  • 27
  • 39
3

I had the same issue. I was in stable channel and doing below solve the issue:

flutter clean 

flutter pub get 

flutter pub cache repair

I hope solve your problem.

MD MEHEDI HASAN
  • 2,044
  • 2
  • 19
  • 34
2

I had the same issue.I used inspect code on chrome and checked console section.So there was error not allowed to load local resource and a Path to some file was like this:

import 'file:///C:/Users/../someFile.dart';

And by changing path to

import 'package:.../someFile.dart'

white screen gone and problem solved.

Zahra
  • 2,231
  • 3
  • 21
  • 41
1

I didn't pay attention to this part from the documentation,"run the application using a static HTTP server.". I was just opening the index.html not using it is server.

Xoltawn
  • 1,445
  • 1
  • 11
  • 17
1

For me I was in master channel and doing below solve the issue:

flutter channel dev
flutter upgrade
flutter run -d chrome
Blasanka
  • 21,001
  • 12
  • 102
  • 104
1

just run flutter config --enable-web in your command line and close your editor and after run the app again

David Baruka
  • 121
  • 1
  • 3
1

I had the same issue. I was in master channel and doing below solve the issue:

flutter clean 

flutter pub get 

flutter pub cache repair

MD MEHEDI HASAN
  • 2,044
  • 2
  • 19
  • 34
1

I had the same problem with my app running as a blank page in Chrome. I've fixed it by re-creating a project with flutter create .:

  1. move your lib directory and pubspec.yml file to a safe place.
  2. then, delete the rest of the files and directories in your project directory.
  3. run flutter create ..
  4. move back in those files from step 1.
Sevastyan Savanyuk
  • 5,797
  • 4
  • 22
  • 34
1

form me was to replace

<base href="$FLUTTER_BASE_HREF">

to

<base href="">

in index.html file

s.mhmd
  • 187
  • 10
  • 2
    currently, this does not work. Ended with error: Error: The base href in "web/index.html" must be absolute (i.e. start with "/"), but found: ``. – Juanes30 Mar 08 '23 at 04:12