'error in flutter "external T operator [](int index); "
This code is showing error "RangeError (index): Invalid value: Not in inclusive range 0..10: 25" in debugging mode. or this external T operator [](int index); // index: 25
List<int> _available = [];
if (5 == 5 ){
for(i = 11; i<=24; i++ ){
_available.add(i);
}
}
List<int> _availableMinutes = [0, 10, 30, 45, 50];
________________
showCustomTimePicker(
context: context,
onFailValidation: (context) {
return showMessage(context, 'Unavailable selection.');
},
initialTime: TimeOfDay(
hour: _available[i],
minute: _availableMinutes.first),
selectableTimePredicate: (time) {
return _available.indexOf(time!.hour) != -1 &&
_availableMinutes.indexOf(time.minute) != -1;
}).then(
(time) =>
setState(() => selectedTime = time?.format(context))
);
Solution 1:[1]
initialTime: TimeOfDay(
hour: _available.first,
minute: _availableMinutes.first)
Solution 2:[2]
I think error is that line:
_availableMinutes.indexOf(time.minute)
Does selectableTimePredicate allow select value "25"? If yes, then error make sense.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sonalika Shrivastava |
| Solution 2 | Captivity |
