checkNotNegative method

int checkNotNegative (
  1. int value,
  2. [String name,
  3. String message]

Check that an integer value is non-negative.

Throws if the value is negative.

If name or message are provided, they are used as the parameter name and message text of the thrown error. If name is omitted, it defaults to index.

Returns value if it is not negative.


static int checkNotNegative(int value, [String name, String message]) {
  if (value < 0) throw RangeError.range(value, 0, null, name, message);
  return value;