Open calii23 opened 2 years ago
My expectation here would be that we just keep up the app's splash screen until the localization delegate is loaded. Is your splash screen by any chance just black?
@goderbauer Which kind of splash screen do you mean? If you mean the one from iOS which are given as LaunchScreen
(I think there is an equivalent in Android too), that screen is only rendered until the flutter engine has started. Meaning that as soon as the flutter engine is there, the new storyboard is displayed. When the root widget now isn't rendering any visible widget (as it is when there is only an empty Container
) the screen stays black.
When having a localization delegate which loads asynchronously, the app renders a black screen as long as it is loading
Hi,
We hit the same issue in our app. We debugged it down and found the following:
As soon as the load
method in the LocalizationDelegate does not return a SynchronousFuture
the issue occurrs. The reason is that when there is a "normal" Future
, e.g. with the following code:
Future<MyLocalization> load(Locale locale) async {
await Future.delayed(const Duration(seconds: 10));
return MyLocalization();
}
the build
method in the localization.dart
returns an empty Container
. When this empty container is visible, the described issue occurs.
When the load
method returns a Synchronous
future it is processed differently and therefore it works.
Hope this helps.
Regards, Florian
Use case
When having a localization delegate which loads asynchronously, the app renders a black screen as long as it is loading. Example:
In this case, the app will show a black screen for 10 seconds, after that it shows a text "Hello World". But it is currently not possible to render a custom loading screen easily.
We would like to have that option, because we are loading the locale bundles from a remote server. This might take a bit time depending on the user's internet connection. But in the moment, this causes the app to show a black screen on every startup.
Proposal
The
Localizations
widget, currently renders an empty container during loading:https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/localizations.dart#L574
It would be sufficient for us, when there is a property, in which a widget can be passed for the loading, like that:
The only workaround I found currently is something like that: