outOfRange method

String outOfRange(
  1. String inner,
  2. int count,
  3. int index
)

An nth index past the end of what its target matched.

Both halves are named because both are wrong in different calls, and the exception underneath tells them apart badly: elementAt says "no indices are valid" when the target matched zero widgets, which never mentions the count that is the actual problem, and reads like a complaint about the index when the index is the one part that was fine.

Implementation

String outOfRange(String inner, int count, int index) =>
    '$inner matches $count widget${count == 1 ? '' : 's'}, so `nth` index '
    '$index is out of range: '
    '${count == 1 ? 'the only index is 0' : 'valid indices are 0–${count - 1}'}.';