Home > Back-end >  error in flutter "external T operator [](int index); "
error in flutter "external T operator [](int index); "

Time:04-05

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))
                );

CodePudding user response:

 initialTime: TimeOfDay(
                        hour: _available.first,
                        minute: _availableMinutes.first)

CodePudding user response:

I think error is that line:

_availableMinutes.indexOf(time.minute)

Does selectableTimePredicate allow select value "25"? If yes, then error make sense.

  • Related