【Flutter】Flutter で Chrome (Edge) を選択してデバッグ実行ができない

flutter

Flutter で Chrome を選択してデバッグ実行ができませんでした。その内容について説明します。
動作確認環境:Windows 10
実行環境: VSCode

エラー内容

コンソールには以下の内容が出力されていました。

Launching lib\main.dart on Chrome in debug mode...

main.dart:1

Failed to launch browser after 3 tries. Command used to launch it: C:\Program Files\Google\Chrome\Application\chrome.exe --user-data-dir=C:\Users\~~~\AppData\Local\Temp\flutter_tools.8a98e6d7\flutter_tools_chrome_device.8f7cb982 --remote-debugging-port=58549 --disable-background-timer-throttling --disable-extensions --disable-popup-blocking --bwsi --no-first-run --no-default-browser-check --disable-default-apps --disable-translate http://localhost:58534

Failed to launch browser. Make sure you are using an up-to-date Chrome or Edge. Otherwise, consider using -d web-server instead and filing an issue at https://github.com/flutter/flutter/issues.

Exited (sigterm)

とりあえず実行ができないことだけはわかりました。

解決策

いくら調べても解決方法が不明だったため、コンソールに出力されている Web Server を立てる方法に切り替えました。

VSCode のデバッグ構成に以下を追加します。

"args": ["-d", "web-server"]

これでデバッグ実行したところ実行できました。
コンソールに出力された URL にアクセスし Dart の拡張機能をクリックしたところデバッグ実行ができました。

根本の原因は不明でしたが当面はこの設定で実行することにします。

タイトルとURLをコピーしました