5

after:

flutter build web

built is ready in path: build/web

how can I run it locally? without using

flutter run -d chrome
4
  • 2
    the most simple way, step 1: cd build/web, step 2: python -m http.server Commented Oct 31, 2021 at 9:26
  • 1
    or when you dont have python3 installed try one of those: gist.github.com/willurd/5720255 Commented Oct 31, 2021 at 9:30
  • you need a local web server. IIS, apache, nodejs or phython as @pskink mentioned Commented Oct 31, 2021 at 9:55
  • 1
    If your app uses any networking calls or is integrated with any services that do (like firebase), the python server approach won't work due to cross-site policies blocking all actions in modern web browsers. Run a local apache server instead: stackoverflow.com/a/74484793/2057171 Commented Nov 18, 2022 at 4:02

1 Answer 1

3

On Mac

Run the following terminal command to start up an apache server:

$ sudo apachectl start

Then, move the contents of your build/web folder to /Library/WebServer/Documents/

(Note: Index.html base href should be "/" if you had previously modified it)

Now, navigate web browser to localhost

Once done, kill the apache server with the following command:

$ sudo apachectl graceful-stop


On Windows

Download XAMPP, install, allow it to run on local networks if prompted, then launch the XAMPP app (it will likely have launched on its own).

In the XAMPP app, find the row for "Apache" and click the "Start" button to start up the web server

Move the contents of your build/web folder to C:/xampp/htdocs/

(Note: Index.html base href should be "/" if you had previously modified it)

Now navigate web browser to 127.0.0.1/index.html

Once done, open the XAMPP app and click "stop" on the Apache row.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.