Easy_localization: lug on startup black screen.

Created on 4 Sep 2019  路  4Comments  路  Source: aissat/easy_localization

there is a noticable lug on app startup after implementing this package.
at least it would be nice to provide a splash screen feature. like https://pub.dev/packages/animated_splash

All 4 comments

yes, me too.
This happen during load in the delegate

EasylocaLizationDelegate

class EasylocaLizationDelegate extends LocalizationsDelegate<AppLocalizations> {
  final Locale locale;
  final String path;
  final String loadPath;

  ///  * use only the lang code to generate i18n file path like en.json or ar.json
  final bool useOnlyLangCode;

  EasylocaLizationDelegate({
    @required this.locale,
    this.path,
    this.loadPath,
    this.useOnlyLangCode = false,
  });

  @override
  bool isSupported(Locale locale) => locale != null;

  @override
  Future<AppLocalizations> load(Locale value) async {
    final SharedPreferences _preferences =
        await SharedPreferences.getInstance();
    var _codeLang = _preferences.getString('codeL');
    var _codeCoun = _preferences.getString('codeC');
    if (_codeLang == null || _codeCoun == null) {
      //value = Locale(this.locale.languageCode, this.locale.countryCode);
      await _preferences.setString('codeC', value.countryCode);
      await _preferences.setString('codeL', value.languageCode);
    } else
      value = Locale(_codeLang, _codeCoun);
    AppLocalizations localizations = AppLocalizations(value,
        path: path, loadPath: loadPath, useOnlyLangCode: useOnlyLangCode);
    await localizations.load();
    return localizations;
  }

  @override
  bool shouldReload(LocalizationsDelegate<AppLocalizations> old) => true;
}

It would be useful to load delegate before the runApp method so the app would stay in its splash screen

Same issue but I resolved it now, Because I forgot add asset in pubspec.yaml

assets:

  • resources/langs/en-US.json
  • resources/langs/th-TH.json

Hope this can help you.

The one thing can make your app to black screen is "EasyLocalizationProvider", You need to wrap everything with it like this.

Widget build(BuildContext context) {
var data = EasyLocalizationProvider.of(context).data;
data.changeLocale(Locale("th","TH"));
return EasyLocalizationProvider(
data: data,
child: MaterialApp(
...
...

anyone has solution for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jerrywyx picture Jerrywyx  路  4Comments

basketball-ico picture basketball-ico  路  6Comments

fatimahossny picture fatimahossny  路  4Comments

Melak12 picture Melak12  路  4Comments

AdelMahmoudHussein picture AdelMahmoudHussein  路  7Comments