getMessage method

String? getMessage({
  1. required String? txt,
  2. String? lang,
})

Returns the translated text paired with the key txt.

If txt doesn't exist for a certain language or the lang is not defined in the Map,

txt is returned as-is.

Implementation

String? getMessage({required String? txt, String? lang}) {
  lang ??= currentLanguage;
  if (txt == null) {
    return txt;
  }
  return (_messages[lang] ?? <String, dynamic>{})[txt] ?? txt;
}