[Flutter Error]The following RangeError was thrown building KeyedSubtree-[<0>]: RangeE

2021-03-01 12:25

阅读:756

标签:art   ror   解决方法   erro   new   sub   err   container   view   

错误:

The following RangeError was thrown building KeyedSubtree-[]:
RangeError (index): Invalid value: Valid value range is empty: 0

原因:

运行时还没获取到数据,就执行了 类似这样的数据输出,
child: Text(‘${this._newsDataList[index].title}‘

解决方法:对数据是否获取到进行判断。

添加 this._newsDataList.length > 0

return this._newsDataList.length > 0
    ? ListView.builder(
    ...
)
    : Container(
        margin: EdgeInsets.all(ScreenAdapter.setHeight(20)),
        height: ScreenAdapter.setHeight(800),
    );

[Flutter Error]The following RangeError was thrown building KeyedSubtree-[]: RangeError (index): Invalid value: Valid value range is empty: 0

标签:art   ror   解决方法   erro   new   sub   err   container   view   

原文地址:https://www.cnblogs.com/TobuTobu/p/14350918.html


评论


亲,登录后才可以留言!