get static method

String get(
  1. String key, {
  2. String? fallbackValue,
  3. Map<String, dynamic>? attributes,
  4. Transform transform = Transform.none,
})

return a string resource.

Implementation

static String get(String key,
    {String? fallbackValue,
    Map<String, dynamic>? attributes,
    Transform transform = Transform.none}) {
  var value =
      _strings[key] ?? _strings[key.toLowerCase()] ?? fallbackValue ?? key;
  if (attributes != null) {
    for (var key in attributes.keys) {
      var keyValue =
          attributes[key] != null ? attributes[key].toString() : "";
      value = value.replaceAll("{$key}", keyValue);
    }
  }

  switch (transform) {
    case Transform.upper:
      return value.toUpperCase();
    case Transform.lower:
      return value.toLowerCase();
    case Transform.capitalize:
      return value.toCapitalized();
    case Transform.title:
      return value.toTitleCase();
    default:
      return value;
  }
}