Skip to content

Allow selecting multi-digit device options#186184

Merged
auto-submit[bot] merged 9 commits into
flutter:masterfrom
faheemabbas766:flutter-tool-multi-digit-device-selection
Jun 3, 2026
Merged

Allow selecting multi-digit device options#186184
auto-submit[bot] merged 9 commits into
flutter:masterfrom
faheemabbas766:flutter-tool-multi-digit-device-selection

Conversation

@faheemabbas766

Copy link
Copy Markdown
Contributor

Allows the interactive flutter run target-device prompt to accept multi-digit device numbers when 10 or more devices are available.

Previously, the prompt used single-character input, so pressing 1 immediately selected device [1] and prevented selecting devices like [10] or [11].

For 1-9 devices, the existing single-character behavior is preserved. For 10+ devices, the prompt switches to line input, allowing selections like 10 and 11 to be entered.

Fixes #186182

Tests

./bin/flutter test packages/flutter_tools/test/general.shard/runner/target_devices_test.dart

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), or this change does not require documentation updates.
  • I added new tests to check the change I am making.
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported, or this change is not a breaking change.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The changes implement line-based input for target device selection when ten or more devices are available, replacing the previous single-character limitation. This includes updates to TargetDevices and TargetDeviceSelection classes, a new validation helper, and a corresponding test case. Review feedback identifies opportunities to refactor duplicated input logic and recommends replacing a busy-wait loop in the FakeTerminal test mock with a StreamController to improve efficiency and test reliability.

Comment thread packages/flutter_tools/lib/src/runner/target_devices.dart Outdated
Comment thread packages/flutter_tools/test/general.shard/runner/target_devices_test.dart Outdated
@bkonyi bkonyi added the CICD Run CI/CD label May 26, 2026
@bkonyi bkonyi requested review from bkonyi and chingjun June 1, 2026 16:15
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 1, 2026
@bkonyi bkonyi added the CICD Run CI/CD label Jun 1, 2026

@bkonyi bkonyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this LGTM! I've rerun the checks to verify, but this change might need to be formatted before it can be approved.

Comment thread packages/flutter_tools/test/general.shard/runner/target_devices_test.dart Outdated
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 1, 2026
@faheemabbas766 faheemabbas766 requested a review from bkonyi June 1, 2026 17:34
@bkonyi bkonyi added the CICD Run CI/CD label Jun 1, 2026
bkonyi
bkonyi previously approved these changes Jun 1, 2026
Comment thread packages/flutter_tools/lib/src/runner/target_devices.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/target_devices.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/target_devices.dart Outdated
Comment thread packages/flutter_tools/lib/src/runner/target_devices.dart Outdated

@chingjun chingjun left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit.

Future<String> readLine() {
return (_broadcastStdInLines ??= _stdio.stdin
.transform<String>(utf8AllowMalformed.decoder)
.transform<String>(const LineSplitter())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Use utf8AllowMalformedLineDecoder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the nit. I updated readLine() to use utf8AllowMalformedLineDecoder and reran the relevant tests/analyzer locally.

@faheemabbas766 faheemabbas766 requested review from bkonyi and chingjun June 2, 2026 06:28
@bkonyi bkonyi added the CICD Run CI/CD label Jun 2, 2026
@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 2, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Jun 2, 2026
Merged via the queue into flutter:master with commit bb8f4f3 Jun 3, 2026
165 of 166 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 3, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 3, 2026
…11832)

Manual roll requested by tarrinneal@google.com

flutter/flutter@701665b...2ba5420

2026-06-03 engine-flutter-autoroll@skia.org Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511)
2026-06-03 mdebbar@google.com Add new file patterns for team-web labeler (flutter/flutter#187397)
2026-06-03 engine-flutter-autoroll@skia.org Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483)
2026-06-03 chris@bracken.jp [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502)
2026-06-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478)
2026-06-03 bkonyi@google.com [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953)
2026-06-03 flar@google.com [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460)
2026-06-02 burak.karahan@mail.ru Remove Material imports from painting tests (flutter/flutter#186937)
2026-06-02 awolff@google.com Add android_hardware_smoke_test integration tests (flutter/flutter#187130)
2026-06-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187471)
2026-06-02 pq@users.noreply.github.com [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780)
2026-06-02 30870216+gaaclarke@users.noreply.github.com Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316)
2026-06-02 116356835+AbdeMohlbi@users.noreply.github.com Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631)
2026-06-02 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331)
2026-06-02 engine-flutter-autoroll@skia.org Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441)
2026-06-02 faheemabbas766@gmail.com Allow selecting multi-digit device options (flutter/flutter#186184)
2026-06-02 puneetkukreja98@gmail.com Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571)
2026-06-02 sanaullah.383@hotmail.com Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807)
2026-06-02 bkonyi@google.com [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369)
2026-06-02 mvincentong@gmail.com Clean up avoid_type_to_string suppressions (flutter/flutter#186869)
2026-06-02 202459002+Lukes-Lair@users.noreply.github.com Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354)
2026-06-02 154381524+flutteractionsbot@users.noreply.github.com Revert "[Impeller] Allow attaching specific texture mip levels and slices" (flutter/flutter#187445)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…lutter#11832)

Manual roll requested by tarrinneal@google.com

flutter/flutter@701665b...2ba5420

2026-06-03 engine-flutter-autoroll@skia.org Roll Packages from 818b310 to b11504f (8 revisions) (flutter/flutter#187511)
2026-06-03 mdebbar@google.com Add new file patterns for team-web labeler (flutter/flutter#187397)
2026-06-03 engine-flutter-autoroll@skia.org Roll Skia from 279b17fe9fc1 to d625048c853a (12 revisions) (flutter/flutter#187483)
2026-06-03 chris@bracken.jp [SwiftPM] Fix prefer_initializing_formals lint (flutter/flutter#187502)
2026-06-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from q27k7_um1GvVrySZS... to ap7MhLX4TdpWRrLS_... (flutter/flutter#187478)
2026-06-03 bkonyi@google.com [SwiftPM] Fix concurrent directory/file/symlink creation crashes (flutter/flutter#186953)
2026-06-03 flar@google.com [Impeller] Fix positioning of text shadow masks (flutter/flutter#187460)
2026-06-02 burak.karahan@mail.ru Remove Material imports from painting tests (flutter/flutter#186937)
2026-06-02 awolff@google.com Add android_hardware_smoke_test integration tests (flutter/flutter#187130)
2026-06-02 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187471)
2026-06-02 pq@users.noreply.github.com [flutter tool] propagate analytics env to sub-tools (flutter/flutter#186780)
2026-06-02 30870216+gaaclarke@users.noreply.github.com Adds macro for fragment shaders to support flutter <= 3.44 (flutter/flutter#187316)
2026-06-02 116356835+AbdeMohlbi@users.noreply.github.com Small clean-up in different java files under `engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/` (flutter/flutter#186631)
2026-06-02 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify ui.Path code for CanvasKit and Skwasm (flutter/flutter#187331)
2026-06-02 engine-flutter-autoroll@skia.org Roll Packages from f5d50ca to 818b310 (2 revisions) (flutter/flutter#187441)
2026-06-02 faheemabbas766@gmail.com Allow selecting multi-digit device options (flutter/flutter#186184)
2026-06-02 puneetkukreja98@gmail.com Improve error message for type mismatch in Navigator.pop and maybePop. (flutter/flutter#186571)
2026-06-02 sanaullah.383@hotmail.com Remove semantics_tester import from material_button_test.dart (flutter/flutter#184807)
2026-06-02 bkonyi@google.com [flutter_tools] Refactor hostPlatform to use Abi.current() (flutter/flutter#185369)
2026-06-02 mvincentong@gmail.com Clean up avoid_type_to_string suppressions (flutter/flutter#186869)
2026-06-02 202459002+Lukes-Lair@users.noreply.github.com Update Flutter documentation links in flutter_console.bat (flutter/flutter#187354)
2026-06-02 154381524+flutteractionsbot@users.noreply.github.com Revert "[Impeller] Allow attaching specific texture mip levels and slices" (flutter/flutter#187445)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@bkonyi bkonyi added the cp:beta label Jun 11, 2026
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
Allows the interactive `flutter run` target-device prompt to accept
multi-digit device numbers when 10 or more devices are available.

Previously, the prompt used single-character input, so pressing `1`
immediately selected device `[1]` and prevented selecting devices like
`[10]` or `[11]`.

For 1-9 devices, the existing single-character behavior is preserved.
For 10+ devices, the prompt switches to line input, allowing selections
like `10` and `11` to be entered.

Fixes flutter#186182

## Tests

```console
./bin/flutter test packages/flutter_tools/test/general.shard/runner/target_devices_test.dart
```

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`),
or this change does not require documentation updates.
- [x] I added new tests to check the change I am making.
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported, or this change is not a breaking change.
- [x] All existing and new tests are passing.

---------

Co-authored-by: Ben Konyi <bkonyi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp:beta cp:stable tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tool] Cannot select device 10 or later from flutter run device prompt

4 participants