You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[flutter_tools] RangeError in TargetDeviceSelection.userSelectDevice #129191
RangeError: RangeError (index): Invalid value: Not in inclusive range 0..1: -1
at List.[](growable_array.dart:264)
at TargetDeviceSelection.userSelectDevice(target_devices.dart:778)
at <asynchronous gap>(async)
at TargetDevicesWithExtendedWirelessDeviceDiscovery._selectFromDevicesAndCheckForWireless(target_devices.dart:707)
at <asynchronous gap>(async)
at RunCommand.validateCommand(run.dart:535)
at <asynchronous gap>(async)
at FlutterCommand.verifyThenRunCommand(flutter_command.dart:1481)
at <asynchronous gap>(async)
at FlutterCommand.run.<anonymous closure>(flutter_command.dart:1297)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at CommandRunner.runCommand(command_runner.dart:212)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand.<anonymous closure>(flutter_command_runner.dart:336)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at FlutterCommandRunner.runCommand(flutter_command_runner.dart:284)
at <asynchronous gap>(async)
at run.<anonymous closure>.<anonymous closure>(runner.dart:115)
at <asynchronous gap>(async)
at AppContext.run.<anonymous closure>(context.dart:150)
at <asynchronous gap>(async)
at main(executable.dart:91)
at <asynchronous gap>(async)
I think the answer is to have an explicit check that this user input is a valid list index.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
christopherfujino commentedon Jun 20, 2023
cc @eliasyishak
andrewkolos commentedon Jun 20, 2023
This code may or may not be relevant:
flutter/packages/flutter_tools/lib/src/runner/target_devices.dart
Line 149 in 8fcb74d
vashworth commentedon Jun 20, 2023
I think just need to add a check that deviceIndex >= 0
flutter/packages/flutter_tools/lib/src/runner/target_devices.dart
Lines 777 to 779 in 8fcb74d
I think this is occuring because when it displays the list of devices like
If you type 0, it accepts it because it's a valid number, but it's not a valid device option
flutter/packages/flutter_tools/lib/src/runner/target_devices.dart
Line 791 in 8fcb74d
eliasyishak commentedon Jun 20, 2023
@vashworth thanks for the heads up! Seems simple enough, feel free to grab this PR if you have time today, I was planning on getting to this tomorrow
Prevent crashes on range errors when selecting device (#129290)
eliasyishak commentedon Jun 22, 2023
Closing with the following PR being merged into master
github-actions commentedon Jul 6, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.