Short answer
Find the list[index] call in the stack trace. In ListView.builder, set itemCount to the same list you index (itemCount: items.length). In loops, use i < list.length, not <=. Before list[0] or .first, check list.isNotEmpty, or use elementAtOrNull and handle null.
Why the index is out of range, and the fix
01
ListView.builder or GridView.builder with the wrong itemCount
“The itemBuilder callback will be called only with indices greater than or equal to zero and less than itemCount.” Flutter, ListView.builder
A hard-coded count, or the length of a different list, makes the builder ask for items that don’t exist. Use the length of the exact list the builder reads.
ListView.builder( itemCount: items.length, itemBuilder: (context, index) => ItemTile(item: items[index]), )02
An off-by-one loop or a fixed index
“The index must be a valid index of this list, which means that index must be non-negative and less than length.” Dart, List operator []
for (var i = 0; i <= list.length; i++) runs one step too far, and list[2] fails as soon as the API returns two items. Loop with < or for-in, and read fixed positions only after checking the length.
for (final item in items) { /* ... */ } final third = items.length > 2 ? items[2] : null;03
An empty list read before the data arrives
“Error thrown due to an argument value being outside an accepted range.” Dart, RangeError class
Valid value range is empty: 0 means the list had no items, often on the first build before a fetch finishes or when a search returns nothing. Show a loading or empty state, or read safely.
if (items.isEmpty) return const Text('No results'); final first = items.elementAtOrNull(0);
Checked against the vendor’s docs on : Flutter API: ListView.builder; Dart API: List operator []; Dart API: RangeError.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: Flutter “Bad state: No element” · Flutter “Null check operator used on a null value” · Flutter “Map is not a subtype of type List” · Flutter “type 'Null' is not a subtype of type 'String'”