Marek
Marek

Reputation: 219

Flutter range error not in inclusive range

I have created a button, which is changing bool value, but when i click button so fast in row then it throw this error:

RangeError (index): Invalid value: Not in inclusive range 0..3: 4

Upvotes: 2

Views: 648

Answers (2)

Marek
Marek

Reputation: 219

I had 2 list of texts and i wanted it to generate one of them when bool value was true or false. So I use this code

or ? truths[Random().nextInt(truths.length - 1)] : dares[Random().nextInt(dares.length - 1)]

insted of this code

or ? truths[Random().nextInt(truths.length)] : dares[Random().nextInt(dares.length)]

Upvotes: 0

Robert Sandberg
Robert Sandberg

Reputation: 8607

It sounds like you are chaning some list on that page. Maybe based on that bool value that is changed when you are pressing the button.

Upvotes: 1

Related Questions