aissat / easy_localization

Easy and Fast internationalizing your Flutter Apps
https://pub.dev/packages/easy_localization
MIT License
902 stars 324 forks source link

Black screen between splash screen and first screen #380

Open JErazo7 opened 3 years ago

JErazo7 commented 3 years ago

The problem occurs when my JSON file becomes too large, as I delete at least 5 random keys and it works perfectly again.

Yayo-Arellano commented 3 years ago

I was having this issue too, the only way I could solve was to use code generation and instead of loading the json file from assets I used the generated class.

MuhammadSufyanMalik commented 3 years ago

did you guys face this issue for ios side, ? https://github.com/aissat/easy_localization/issues/381

wh120 commented 3 years ago

A problem is when set backgroundColor: Colors.transparent,

Overman775 commented 3 years ago

its because preloader widget was been removed from 3.0.0 https://github.com/aissat/easy_localization/blob/develop/CHANGELOG.md#300

Add your own colored background widget or use your own solution

ColoredBox(
    color: Colors.red,
    child: EasyLocalization(
Overman775 commented 3 years ago

The blinking appears because the localization is loaded asynchronously and when it is not there, the app bg is shown(black)

omidraha commented 3 years ago

I have same issue fixed as below, Here is my code, Also I think the context.setLocale doesn't have normal behavior inside of FutureBuilder.

return FutureBuilder<bool>(
  future: changeLocale(
    context: context,
    languageCode: languageCode,
  ),
  builder: (context, snapshot) {
    if (snapshot.data == null) {
      return SafeArea(
        child: Scaffold(
          body: progressLoading(),
        ),
      );
    }
    return SplashScreen();
  },
);

.


Future<bool> changeLocale({
  required BuildContext context,
  required String languageCode,
}) async {
  Future<bool> _setLocale() async {
    await context.setLocale(
      getLocaleByCountry(languageCode)!,
    );
    return true;
  }

  return await _setLocale();
}
RoPB commented 2 years ago

Nice package but I can not use it because of this.

The problem as @Overman775 says its related to asyncronously locale load. Here is a good explanation about what is going on using flutter_intl https://github.com/Racinggavin/black_screen_inv (different but the same problem under the hood)

The solution I found was following exactly what it is described at the official flutter doc: https://flutter.dev/docs/development/accessibility-and-localization/internationalization However I loose lot of capabilities such as plurals etc.

aBuder commented 1 year ago

The blinking appears because the localization is loaded asynchronously and when it is not there, the app bg is shown(black)

Is there any solution to show preloader widget? In previous version, this was available