crashlytics指向此错误RangeError(length):无效值:有效值范围为空:0.错误抛出null



我在这一行有一个错误

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

错误

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

我不知道为什么我有一个null错误,我检查dateList1[0]是否=null

这是我的代码

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

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

dateList1可能为空,因此索引0不存在。你可以检查一下它是否像一样空

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

最新更新