initLanguage method

Language initLanguage()

Implementation

Language initLanguage() {
  final Locale? deviceLocale = Get.deviceLocale;
  final Language? selectLanguage =
      SpUtil.getObj(BaseConfig.keyLanguageJson, (Map v) => Language.fromJson(v as Map<String, dynamic>));
  //首次设置,使用系统的,没有再默认英文
  if (selectLanguage == null) {
    final List<Language> list = getLanguages();

    for (final element in list) {
      if (deviceLocale!.languageCode == element.languageCode ||
          element.languageCode.contains(deviceLocale.languageCode)) {
        setLocalModel(element);
        return element;
      }
    }
    return list[0];
  }
  return selectLanguage;
}