flutter given error while running: Error waiting for a debug connection: Bad state: No element

Run flutter clean.

This works for me.


I had this error with a clean install on MacOS X (Mojave), and after trial and error discovered that the main user who is running flutter debug needs to be an admin user.

Clue was the line:

log: Must be admin to run 'stream' command

when running from command line.

After this VS Code and command line work.


Build always works on my VS code normally. Updating to the latest Flutter 1.12 also started showing this and most times, my code either shows up on my device first before showing that debug has started or the program just quits. Any fix with VS code because I am not an Android Studio fan.

Tags:

Dart

Flutter