Prevent crashes on range errors when selecting device (#129290)
Prevent the cli from crashing when a user selects a number that is not valid for `flutter run` device selection Fixes issue: - https://github.com/flutter/flutter/issues/129191 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
@@ -774,7 +774,7 @@ class TargetDeviceSelection {
|
||||
throwToolExit('');
|
||||
}
|
||||
final int deviceIndex = int.parse(userInputString) - 1;
|
||||
if (deviceIndex < devices.length) {
|
||||
if (deviceIndex > -1 && deviceIndex < devices.length) {
|
||||
chosenDevice = devices[deviceIndex];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user