Home > Mobile >  crashlytics point this error RangeError (length): Invalid value: Valid value range is empty: 0. Erro
crashlytics point this error RangeError (length): Invalid value: Valid value range is empty: 0. Erro

Time:08-14

I have an error at this line

if (dateList1[0]==""||dateList1[0]==null){

error

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: RangeError (length): Invalid value: Valid value range is empty: 0. Error thrown null.

I don't know why I have a null error, I check if dateList1[0]==null

Here is my code

      var dateList1;

      int indexToRemove = 0;

      List newList = dateList0.where((x) => dateList0.indexOf(x) != 
      indexToRemove).toList();
      
      dateList1=newList;

      if (dateList1[0]==""||dateList1[0]==null){

CodePudding user response:

There is a chance that dateList1 is empty so the index 0 doesn't exist. You can do a check to find if its empty too like

if (dateList1.length > 0 && (dateList1[0]==""||dateList1[0]==null)){
  • Related