1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Flutter/Dart】RangeError (index): Invalid value: Valid value range is empty: 0 のエラーの解決方法

1
Posted at

Flutterでアプリを開発中、Widget周りでよく出てきたエラーだったので、解決方法をメモとして残させて頂きます。

エラー内容

List.builderでWidgetを開発中に下記のエラーが出現....

RangeError (index): Invalid value: Valid value range is empty: 0

解決方法

下記のように、itemCountの値を指定することで上記エラーは解消できます。
(エラーが出た時点はitemCountのプロパティの値を指定していませんでした。)

ListView.builder(
            itemCount: items.length,
            itemBuilder: (ctx, index) {
              return ExampleWidget();
            });

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?