Photo by Etienne Girardet on Unsplash
How to fix Dart Lang Error: RangeError (index): Index out of range: no indices are valid: 0
In C-like languages like JS, it's a common operation to assign a value to an array in a for
loop at a given index using []. Like this:
With Dart lang trying this:
You get the error: RangeError (index): Index out of range: no indices are valid: 0
The solution is to use List's insert method .insert(i, value)
or .add(value)
.