简体   繁体   中英

Debug Flutter web app in VS Code without creating a Microsoft Edge new instance

everything is set up and working but when I start debugging flutter in vs code using microsoft edge it starts a new instance, meaning the browser data, password, settings.... are all reset, so i need to enter passwords and change settings every time i start debugging or i need to open two browser instances which is both resources intensive and clingy. is there like vs code configuration for flutter that works as "attach" to an existing browser instance instead of "launch" a new instance?

Normally, if Microsoft Edge is already running when you start debugging with a launch config, then the new instance won't start in remote debugging mode.

So by default, the extension launches Microsoft Edge with a separate user profile in a temp folder. Use userDataDir to set a different path to use, or set to false to launch with your default user profile.

A simple example:

{
    "configurations": [
        {
            "name": "Launch Microsoft Edge",
            "request": "launch",
            "type": "edge",
            "url": "...\\Index.html", // Provide your project's url to finish configuring
            "userDataDir": false // You could also add ${local_app_data}\Edge\Profile, such as C:\Users\<Current-user>\AppData\Local\Microsoft\Edge\Profile
        }
    ]
}

you have to run with following command,

flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0

then access http://<your-ip> or localhost:8080

with this you can open your flutter web-app in regular browser and also you can open it in other devices in network(with your ip) ** also you should ensure that your port(8080) is open.

I don't have a perfect solution, as this one requires you to install the Dart Debug Extension , but you can create a launch.json and paste this command:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter Web Project",
            "type": "dart",
            "request": "launch",
            "program": "lib/main.dart",
            "args": [
                "-d",
                "web-server"
            ]
        }
    ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM