0

I have created SplashScreens for my Flutter app for both iOS and Android using the native way which is editing the LaunchScreen.storyboard and it is working currently when I run my app but the SplashScreen does not hold long enough and is there a way to programmatically hide the native splashscreen in dart after I am done with some data processing and logic?

The solutions I found online are all flutter apps with SplashScreen that is build using flutter widgets and not the native way...

zernzern1993
  • 235
  • 8
  • 19

1 Answers1

0

Even if you build the splash screen if Flutter, you still need to set one in via XCode. Otherwise, the app loads with a momentary plan white screen and Apple rejects it.

If you want to extend the time till the moment data process is over, then you will have to make a replica of LaunchScreen.storyboard in Flutter. The data processing and logic are written in Flutter. There's no way it can tell LaunchScreen.storyboard "I am done". What you can do is though, make a splash screen in Flutter which will look like LaunchScreen.storyboard. And once the data processing is done, you can navigate the user to the desired screen. Since the two screens are same, use won't see the difference and the app will smoothly show the next screen.

Just a word of caution - be careful about extending the timing of launch screen. Apple may reject the app. See if something can be done after the screen load. You can use flutter after layout package for this or the below line will do the trick :

WidgetsBinding.instance
        .addPostFrameCallback((_) => myFunction(context));

This thread may help you to delay the screen for XX seconds.

Sukhi
  • 13,261
  • 7
  • 36
  • 53
  • Thanks for commenting, I already and only did the configuration for XCode and AndroidStudio and did not do a custom splashscreen on the dart files... Is there a way to for me a call an api wait for the response and then only hide the splashscreen? Native splashscreen, not flutter's – zernzern1993 May 06 '20 at 11:09
  • AFAIK, that is not possible. The Flutter app starts after LaunchScreen.storyboard. There's no way we continue with LaunchScreen.storyboard, initialise Flutter app, do the API calls n all and ask LaunchScreen.storyboard to unload itself. – Sukhi May 06 '20 at 11:13
  • ohhh damn... guess I have to stick to the flutter splash screen way ! Thanks a lot mate ! – zernzern1993 May 06 '20 at 12:19