lookup method

String lookup(
  1. String key, {
  2. Map<String, Object>? namedParameters,
})

Returns a string specified by key from the loaded yaml file.

By passing parameters to namedParameters, formatting compliant with MessageFormat is possible.

This method is called from the l method.

Implementation

String lookup(String key, {Map<String, Object>? namedParameters}) {
  final tValue = _map[key];

  if (tValue == null) {
    return key;
  }

  if (tValue is MessageFormat) {
    return tValue.format(namedParameters ?? const {});
  } else {
    return tValue.toString();
  }
}