How to run Flutter on Web

To run Flutter in a web environment using the terminal, you first need to make sure your project is set up for web development. Follow these steps:

Step 1: Enable Web Support for Flutter

  1. Open your terminal and type:

    flutter channel stable
    

    This ensures that you're using the stable version of Flutter.

  2. Next, enable web support by running:

    flutter config --enable-web
    

  3. Verify that web support is enabled by running:

    flutter devices
    

    You should see Chrome or another web browser listed as an available device.

Step 2: Run the Flutter Web App

Open your Flutter Project

  1. To run your Flutter project in the web browser, simply type:

    flutter run -d chrome
    

    The -d chrome flag tells Flutter to run the project in Chrome.

  2. If you want to build it for production, you can use:

    flutter build web
    

    This will generate the production-ready files in the build/web folder.

Step 5: Open the Web App

When running flutter run -d chrome, it should automatically open the app in your default web browser. If it doesn’t, you can manually open the URL provided in the terminal (usually something like http://localhost:5000).

Updated on