init method

Future<void> init({
  1. required List<MapLocale> mapLocales,
  2. required String initLanguageCode,
  3. String? initCountryCode,
})

Initialize the list of mapLocale (see MapLocale model for info) and initLanguageCode code when the app is start up. Both field will required.

initLanguageCode mostly passed from the shared_preferences for checking the init language to display when the app is start up.

Implementation

Future<void> init({
  required List<MapLocale> mapLocales,
  required String initLanguageCode,
  String? initCountryCode,
}) async {
  Translator.instance.mapLocales = mapLocales;
  _supportedLanguageCodes = mapLocales.map((e) => e.languageCode).toList();
  await _handleLocale(initLanguageCode, initCountryCode);
}