parsePositiveInt function
Parses a positive integer from the given value and returns it as an int.
- Throws a FormatException if the
valueis empty, contains an invalid number, is negative, or is not an integer.
Implementation
int parsePositiveInt(final String value) {
final int parsedValue = parseInt(value);
if (parsedValue.isNegative) {
throw const FormatException('Must be non-negative');
}
return parsedValue;
}