toString method

  1. @override
String toString()
override

Returns the translation for the given key as a string.

If the key is not found in the JSON file, it returns the key itself as a fallback. In debug mode, it prints a warning message when a key is not found.

Implementation

@override
String toString() {
  String result = json[key]?.trim() ?? "";
  if (result.isEmpty) {
    if (_isDebug) {
      print(
          "localization_lite: warning ${key} is not defined in ${_langCode}");
    }
    result = key;
  }
  return result;
}