checkCoords static method

void checkCoords(
  1. int atLeastLen,
  2. Iterable<num> coords, {
  3. int? offset,
  4. int? length,
})

Throw if coords do not have atLeastLen values.

Use optional offset and length params to define a segment on coords.

Implementation

static void checkCoords(
  int atLeastLen,
  Iterable<num> coords, {
  int? offset,
  int? length,
}) {
  if ((offset == null && length != null) ||
      (offset != null && length == null)) {
    throw const FormatException(
      'Offset and length must be both null or non-null',
    );
  }
  final start = offset ?? 0;
  final len = length ?? coords.length;
  if (start < 0 ||
      start + atLeastLen - 1 >= coords.length ||
      atLeastLen > len) {
    throw const FormatException('Coords segment out of range');
  }
}