FlutterIntermediate 2 min read

Flutter web setup: run your first browser application

Create a web-enabled Flutter project and verify a browser target before changing app code.

On this page

Start with a working Flutter SDK and a supported browser. A browser target is useful for learning and application prototyping, but packages that depend on native device capabilities still need their own platform review.

Create an isolated starter

Run these commands in a folder where you keep projects. The project name below is an example; use a directory that does not already contain another application’s files.

flutter --version
flutter devices
flutter create --platforms=web browser_lab
cd browser_lab
flutter run -d chrome

On a supported Windows setup you can choose the listed Edge device instead. Use the exact device identifier printed by flutter devices. If there is no browser target, verify the browser installation and the web platform setup before modifying widgets.

Verify interaction and iteration

Use the generated counter first. Click the button, change the page title in lib/main.dart and trigger the supported reload operation from your editor or running terminal. Observe whether the current counter state survives. A full browser refresh starts another app instance and is a different operation.

Inspect both the terminal and browser console when a change fails. A compilation diagnostic, blocked API request and layout overflow have different owners. Capture the first meaningful error rather than a long chain of follow-on failures.

Add web to an existing app carefully

Commit the project, inspect whether a customized web/ folder already exists, then use flutter create . --platforms web only when adding the platform is intentional. Review the generated files. Do not delete a customized index page merely to make it resemble a fresh template.

Check each dependency’s supported platforms. Conditional UI alone cannot make a native-only library compile for the browser. Separate platform integrations behind an interface before importing unsupported libraries into shared code.

Verify a production build

flutter analyze
flutter test
flutter build web
python -m http.server 8080 --directory build/web

Open http://localhost:8080 in your browser. Serve the build over HTTP; opening index.html from a file path does not reproduce hosted module loading and routing behavior. The local server is a development verification tool, not a production hosting service.

Exercise

Add a second small screen, navigate to it and refresh the page. Record the URL and the refresh result. Continue with web routing to understand why a development server can hide a missing production rewrite.

How this topic connects

Understand first

Apply it next

Lesson progressMark complete after checking the example and exercise.

Find your next idea

Search lessons, code examples and projects.

Type a few words to start exploring.