getInt method

int? getInt(
  1. String key, {
  2. bool throwException = false,
  3. int? defval,
  4. String? defkey,
})

Loads the value of a property as an integer given its key. Use defval to set a default value in case of missing property. Use defkey to set a default key in case of missing property.

Implementation

int? getInt(
  String key, {
  bool throwException = false,
  int? defval,
  String? defkey,
}) {
  var value = get(key, defval: defval, defkey: defkey);
  if (value == null) {
    return null;
  }

  try {
    return int.parse(value);
  } on FormatException catch (e) {
    if (throwException) {
      throw e;
    }
    return null;
  }
}