get method

dynamic get(
  1. String key, {
  2. dynamic dv = _MISSING,
})

Implementation

dynamic get(String key, {dynamic dv = _MISSING}) {
  dynamic result;

  if ((_cache != null) && _cache!.containsKey(key)) {
    result = _cache![key];
  } else if (_data == null) {
    throw ConfigException('No data in configuration', null);
  } else {
    if (_data!.containsKey(key)) {
      result = evaluate(_data![key]!);
    } else if (isIdentifier(key)) {
      if (identical(dv, _MISSING)) {
        throw ConfigException('Not found in configuration: $key', null);
      }
      result = dv;
    } else {
      // not an identifier. Treat as a path
      _refsSeen.clear();
      try {
        result = _getFromPath(parsePath(key));
      } catch (e) {
        // print('*** GET $e');
        if (e is InvalidPathException ||
            e is CircularReferenceException ||
            e is BadIndexException) {
          rethrow;
        }
        if (identical(dv, _MISSING)) {
          if (e is! ConfigException) {
            rethrow;
          }
          throw ConfigException('Not found in configuration: $key', null);
        }
        result = dv;
      }
    }
  }
  // print('*** $key|$result');
  result = _unwrap(result);
  if (_cache != null) {
    _cache![key] = result;
  }
  return result;
}