getInt method

int getInt(
  1. String key, {
  2. int? defaultValue,
})

Implementation

int getInt(String key, {int? defaultValue}) {
  final s = _env[key];
  if (s == null) {
    if (defaultValue != null) return defaultValue;
    throw StateError('Missing env "$key"');
  }
  final v = int.tryParse(s.trim());
  if (v == null) throw FormatException('Env "$key" is not an int: "$s"');
  return v;
}