option<T> method

T? option<T>(
  1. String key, [
  2. T? def,
  3. TypeElementParser? parser
])

Implementation

T? option<T>(String key, [T? def, TypeElementParser? parser]) {
  var value = _options[key];

  if (value == null) {
    var keyLC = normalizeKey(key);
    value = _options[keyLC];
  }

  if (value == null) return def;

  parser ??= TypeParser.parserFor<T>(obj: def);
  if (parser != null) {
    return parser(value) as T;
  } else {
    return value as T;
  }
}