fix(commands): prevent false positive "Flutter is already running!" s… - #532
Open
zanadoman wants to merge 1 commit into
Open
fix(commands): prevent false positive "Flutter is already running!" s…#532zanadoman wants to merge 1 commit into
zanadoman wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed "Flutter is already running!" when retrying after device pick
What was happening
Sometimes
flutter runexits with:No supported devices connectedMore than one device connectedWhen this happens, the plugin opens a small picker so you can pick a
device, then automatically retries the run with
-d <your-device>.The retry was failing with
Flutter is already running!, even thoughnothing was actually running.
Why
The plugin clears its internal runner state inside
on_run_exit, butit was doing it after showing the device picker:
ui.selectis asynchronous — it shows the picker, then waits for youto pick. Your pick runs later in a callback, and that callback calls
M.runto retry. Butshutdown()hadn't run yet, so the plugin stillthought a runner was active. The retry hit the
is_running()guardand bailed.
Fix
Move
shutdown()to run before the picker:Now by the time the picker callback fires and the retry starts, the
old state is already gone and the retry can proceed.
Also tested it for two days at work, to make sure the fix works!
Thank you for your work!