码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2021-02-01 12:25:15      阅读:0      评论:0      收藏:0      [点我收藏+]

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

错误:

The following RangeError was thrown building KeyedSubtree-[<0>]:
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-[<0>]: 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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!