Git Product home page Git Product logo

Comments (3)

SiyrisSoul avatar SiyrisSoul commented on May 18, 2024

Quick update on this. I just built the app I'm working on in release mode on my physical device and I'm not experiencing this issue! It definitely is noticeable in the emulator and not there without this package, but as far as I'm concerned since it works perfectly in release mode this issue might be able to be closed. I haven't tested the example app yet on my device, but I'm sure it works the same.

from flutter_translate.

bratan avatar bratan commented on May 18, 2024

This is definitely an issue, I could reproduce it on the emulator and from what I can see there are some other open issues (such as flutter/flutter#22007 and flutter/flutter#20827) regarding this behavior.

In our case here, it seems the problem is the localization initialization by Flutter, which happens right after the splash screen is closed and before the main (app) widget is rendered.

If we force the localization initialization before runApp (by calling delegate.changeLocale), the issue is gone, as the localization is initialized during the splash screen instead.

Ex:

void main() async
{
  WidgetsFlutterBinding.ensureInitialized();

  var delegate = await LocalizationDelegate.create(fallbackLocale: 'en_US',supportedLocales: ['en_US', 'es', 'fa']);

  delegate.changeLocale(Locale('en_US'));

  runApp(LocalizedApp(delegate, MyApp()));
}

The problem with this is that on first startup, the current device locale should be used (if supported by the application).

So I think the solution here, in order to have the default locale used on startup and not to have this black screen behavior, is to retrieve the current device locale and initialize it before runApp, instead of letting Flutter decide when to initialize it.

This could be implemented directly in the LocalizationDelegate.create method.

from flutter_translate.

SiyrisSoul avatar SiyrisSoul commented on May 18, 2024

Thanks for the update on this! I'm going to look into implementing that if you haven't already gotten to it before I do.

from flutter_translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.