Skip to main content

Building a web application with Flutter

This page provides an overview of how to configure, run, and build a web application using Flutter.

Requirements

#

Before you can build a web application with Flutter, make sure that you have the Flutter SDK and a web browser installed. See the Set up web development for Flutter instructions for details.

Set up a Flutter project

#

To set up your project, you can create a new Flutter project or add web support to an existing project.

Create a new project

#

To create a new app that includes web support, run the following command:

flutter create my_app

Add web support to an existing project

#

If you already have a project, run the flutter create command in your project directory:

flutter create . --platforms web

This creates a web/ directory containing the web assets used to bootstrap and run your Flutter app.

Run your app

#

Select Chrome as your app's target device to run and debug a Flutter web app:

flutter run -d chrome

You can also choose Chrome as a target device in your IDE.

If you prefer, you can use the edge device type on Windows, or use web-server to navigate to a local URL in the browser of your choice.

Run your app using WebAssembly

#

You can pass the --wasm flag to run your app using WebAssembly:

flutter run -d chrome --wasm

Flutter web offers multiple build modes and renderers. For more information, see Web renderers.

Build your app

#

Run the following command to generate a release build:

flutter build web

Build your app using WebAssembly

#

You can also pass the --wasm flag to build your app using WebAssembly:

flutter build web --wasm

This populates a build/web directory with built files, including an assets directory, which need to be served together.

To learn more about how to deploy these assets to the web, see Build and release a web app. For answers to other common questions, see the Web FAQ.

Debugging

#

Use Flutter DevTools for the following tasks:

Use Chrome DevTools for the following tasks:

Testing

#

Use widget tests or integration tests. To learn more about running integration tests in a browser, see the Integration testing page.