How to run flutter on chrome using visual code editor
Asked Answered
S

4

21

How to run flutter app on chrome. I have installed flutter kit and also run flutter channel beta flutter upgrade and also install extension on visual studio code.

Shimkus answered 11/1, 2020 at 8:48 Comment(1)
do you have flutter version 1.12? if so, follow flutter.dev/docs/get-started/webBaronetcy
F
58

Just like with flutter mobile create flutter launch configuration, but add the following line: "args": [ "-d", "chrome" ]

{
  // launch.json
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Flutter for web",
      "type": "dart",
      "request": "launch",
      "program": "lib/main.dart",
      "args": [
        "-d",
        "chrome"
      ]
    }
  ]
}
Friede answered 11/1, 2020 at 10:3 Comment(2)
It's weird, flutter run -d chrome works fine for me but with this launch config, chrome cannot reach the site :(Compromise
This is what I'm looking for. Thank youDissimulation
P
13

You can write on terminal:

flutter run -d chrome
Ply answered 13/1, 2020 at 15:19 Comment(2)
How do you run the widget selector here then?Clustered
we can use widget selector from vscode itself ,I think its not a problemPly
W
1

@Spatz is correct but I also had right below his answer configuration

{
            "name": "new_app",
            "request": "launch",
            "type": "dart"
        },
        {
            "name": "new_app (profile mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "profile"
        },

I had to delete these from launch.json for VSCode to launch the app in debug mode (able to step through) in Chrome.
Otherwise pushing F5 would start the debug mode but on my device.

Worriment answered 28/10, 2021 at 1:6 Comment(0)
A
1

It's pretty simple if you've installed chrome in your system.. for running in debug mode, run this command in terminal

flutter run -d chrome

For running in release mode

flutter run -d chrome --release

Autobus answered 27/12, 2022 at 13:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.