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

black screen that shows up between the LaunchImage and my app's first screen #17

Closed
jlcool opened this issue Mar 5, 2019 · 17 comments
Closed

Comments

@jlcool
Copy link
Contributor

jlcool commented Mar 5, 2019

when customize launch splash screen

@ilteoood
Copy link
Owner

ilteoood commented Mar 5, 2019

Why this be fault of interest flutter_18?

@jlcool
Copy link
Contributor Author

jlcool commented Mar 5, 2019

I tried not to use flutter_i18n. No problem. I found that load in FlutterI18nDelegate is the reason of async method. My English is not good. I don't know if I can explain it clearly.

@ilteoood
Copy link
Owner

ilteoood commented Mar 5, 2019

Sorry, but without an example or a concrete analysis I don't know where to begin.

@ilteoood ilteoood closed this as completed Mar 5, 2019
@jlcool
Copy link
Contributor Author

jlcool commented Mar 6, 2019

@ilteoood you can try this https://github.com/jlcool/flutter_app_qidongye (android) and I found that load() in FlutterI18nDelegate is the reason of async method

@jlcool
Copy link
Contributor Author

jlcool commented Mar 6, 2019

Android only needs to configure launch_background.xml and flutter_i18n to have this problem. IOS I didn't try.

jlcool added a commit to jlcool/flutter_i18n that referenced this issue Mar 7, 2019
@blntylmn
Copy link

This is really happens when I add FlutterI18nDelegate in localizationsDelegates.. Without FlutterI18nDelegate there is no black screen..

@ilteoood ilteoood reopened this Mar 16, 2019
@blntylmn
Copy link

blntylmn commented Mar 16, 2019

Here:
https://github.com/blntylmn/flutter-splash-screen

uncomment line 20 and 26 in main.dart
and comment lines 27 to 31

you will see the black screen appears.

@ilteoood
Copy link
Owner

For "black screen" you mean that < 10ms image that preceed the ScreenOne?

@blntylmn
Copy link

Nope..
There is 1 to 4 second empty black screen between splash screen and ScreenOne. You can see it much well on android emulator..

ilteoood added a commit that referenced this issue Mar 17, 2019
ilteoood added a commit that referenced this issue Mar 17, 2019
@ilteoood
Copy link
Owner

ilteoood commented Mar 17, 2019

Use the 0.6.3 version and consider to modify your example as follow:

import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n_delegate.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'screen_one.dart';
import 'screen_three.dart';
import 'screen_two.dart';

var router = <String, WidgetBuilder>{
  "/screen-2": (BuildContext context) => ScreenTwo(),
  "/screen-3": (BuildContext context) => ScreenThree(),
};

Future main() async {
  final FlutterI18nDelegate flutterI18nDelegate = FlutterI18nDelegate(
      useCountryCode: false, fallbackFile: 'en', path: 'assets/locales');
  await flutterI18nDelegate.load(null);
  runApp(MaterialApp(
    title: 'Splash Screen',
    theme: ThemeData(
      primaryColor: new Color(0xff622f74),
      accentColor: Colors.orange,
    ),
    localizationsDelegates: [
      flutterI18nDelegate,
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate
    ],
    home: ScreenOne(),
//      home: Scaffold(
//        body: Center(
//          child: Text('Test'),
//        ),
//      ),
    routes: router,
  ));
}

@blntylmn
Copy link

You are aggressively closing all issues whether is solved or not.
Your solution is not working. (yes I installed 0.6.3)
I tried every possible solution but none of them helped. Like below one :

Future main() async {
  final FlutterI18nDelegate flutterI18nDelegate = FlutterI18nDelegate(
      useCountryCode: false, fallbackFile: 'en', path: 'assets/locales');
  runApp(SplashScreen());
  flutterI18nDelegate.load(null).then((onValue) {
    runApp(MaterialApp(
      title: 'Splash Screen',
      theme: ThemeData(
        primaryColor: new Color(0xff622f74),
        accentColor: Colors.orange,
      ),
      localizationsDelegates: [
        flutterI18nDelegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      supportedLocales: [const Locale("en"), const Locale("tr")],
      debugShowCheckedModeBanner: false,
      home: ScreenOne(),
      // home: Scaffold(
      //   body: Center(
      //     child: Text('Test'),
      //   ),
      // ),
      routes: router,
    ));
  });
}

I tried other JSON solutions as well. (like easy_localization)
The problem is when loading delegates waiting for JSON file loading and this causes between splash screen and app screen a black screen.
So I decided to turn back Intl solution. It is a bit hard to maintain and yes it is boring but it works perfect.
No black screen no cry :)
Thanks for your effort btw.

@ilteoood
Copy link
Owner

The problem with your code is that you are doing an async task inside the runApp method. This cause the app to hang and wait the rources to be loaded.
I've tried your example on both android emulator and genymotion, and with the new version the blank screen isn't happening.
I can make you a screen record to prove that but, fortunately, isn't a my problem anymore :)

@blntylmn
Copy link

I tried your suggestion exactly how you write nothing changed then i tried other things..
Anyway you will hear more from this issue in the near future from others. Because it is not working well splash screen and JSON localization together.

@ilteoood
Copy link
Owner

The only thing that I can suggest is to do a Flutter get, flutter upgrade and then a Flutter clean to be sure that you aren't using and old apk build.
Are you @jlcool facing this issue again with the latest version and the example provided above?

@Purus
Copy link

Purus commented Mar 20, 2019

When main() is async, I had the same issue of black screen in the first few frames.

But following the solution provided, the issue is resolved. I can confirm on the same.

@ilteoood
Copy link
Owner

Thank you so much for your contribute, really appreciated!

@jlcool
Copy link
Contributor Author

jlcool commented Mar 21, 2019

It's finally repaired.I've been using #18

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

4 participants