Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lug on startup black screen. #26

Closed
Xgamefactory opened this issue Sep 4, 2019 · 4 comments
Closed

lug on startup black screen. #26

Xgamefactory opened this issue Sep 4, 2019 · 4 comments

Comments

@Xgamefactory
Copy link

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

@ftognetto
Copy link

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

@woody-worakorn
Copy link

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.

@woody-worakorn
Copy link

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(
...
...

@siva563
Copy link

siva563 commented Jan 30, 2020

anyone has solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants