jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.36k stars 215 forks source link

White screen on web when using "FlutterNativeSplash.remove()" #607

Closed eggp closed 1 year ago

eggp commented 1 year ago

Hello,

On the web, when I want to use "FlutterNativeSplash.remove()", a white screen appears for a moment after the splash screen is removed. Example code: https://github.com/eggp/flutter_native_splash_web_flickering_fix/blob/main/lib/main.dart | demo app: https://eggp.github.io/flutter_native_splash_web_flickering_fix/flickering/

I think the solution is simple. Because of the JavaScript eventloop, you have to use the setTimeout(0) trick, which I usually achieve using SchedulerBinding in flutter. Example code: https://github.com/eggp/flutter_native_splash_web_flickering_fix/blob/fix/lib/main.dart#L13 | demo app: https://eggp.github.io/flutter_native_splash_web_flickering_fix/fix/

The problem arises from the fact that Timer is in the widgetsBinding.allowFirstFrame->scheduleWarmUpFrame call chain.

jonbhanson commented 1 year ago

@eggp This is excellent, thanks! I will push an update soon that adds this.