颤振范围错误:无效值:....,包括:-1

Nav*_*een 1 android dart flutter

“包含:-1”在范围错误中是什么意思 RangeError (index): Invalid Value: Not in range 0..6, inclusive: -1

注意:索引是来自

ListView.builder(
  itemBuilder: (context,index) => Widget,
)
Run Code Online (Sandbox Code Playgroud)

jam*_*lin 7

误导性逗号导致您错误解析错误消息。“包含”部分旨在描述范围,而不是无效值。也就是说,错误最好写成:

RangeError (index): Invalid Value: -1 not in range 0..6 (inclusive)

或者

RangeError (index): Invalid Value: -1 not in range [0, 6]

在某个地方,您将 -1 作为索引传递到具有 7 个元素的列表中。

https://github.com/dart-lang/sdk/issues/29586请求改进错误信息。)