how to increase Flutter launch_background.xml Splash Screen display time? - flutter

I've trying to run my app in debug mode, but my app was laggy and didn't get 60fps.
Then i'm trying to run my app in release mode with
flutter run --release
And i got 60 fps, but i got my image in launch_background.xml as Splash Screen disappearing too fast.
How to increase the display time, maybe 3 until 5 seconds, like in debug mode ?
Do me a favor please...

You can't calculate the exact time, It depends on the hardware and platform the application is running on it.
Flutter takes some time to render and this time is different for different devices.
But you can put a delay just before the runApp function, if you need to show the splash screen longer than flutter rendering time. like this:
void main() async {//make your main function async
//put delay here with await:
await Future.delayed(Duration(seconds: 3));
runApp(MyApp());
//total splash time = your delay + the time that Flutter needs to render
}

Related

Flutter : Is using Native Splash Screen better?

I am using flutter_native_splash package. Which works fine. But what is the difference between using the native splash and a flutter page? Is there any difference regarding performance?
when the flutter app is opened for the first time, there will be white screen for few seconds before any page is displayed.
to tackle that issue, flutter_native_splash can be used. It builds a native splash screen and will be displayed for few seconds until the first UI is drawn in the flutter app.
the native splash screen can also be closed programatically if needed it until some async task is done.
The flutter_native_splash displays the splash screen before the Flutter engine is finished loading. If you use a Flutter page for a splash screen, it will be loaded after the Flutter engine is finished loading and there will be a delay during which a blank white screen will be displayed.
(Full disclosure - I maintain the flutter_native_splash package)

how to detect Screen recording in flutter?

Is there any way to detect if screen is getting captured for my app in flutter? I want to turn my screen black if any app/system is recoding screen while my app is active.
Is it possible in flutter?
try this plugin flutter_windowmanager
to prevent screen shot and video record
in main file :
disableCapure() async {
await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE);
}
then call that method after runApp
void main(){
runApp(...);
disableCapure();
}
although for ios you have to know native code maybe it not work pretty for ios

How to know when the app is loaded in Flutter?

In my flutter app I'm playing an animation. And I want to start the playback only after all the widgets on the page have loaded. Essencially I'm looking for the JS equivalnat of window.onload in flutter. Right now the animation starts as soon as it can and the result it that when the app lunches I see a white screen while the app is loading for a few seconds and when the app is finally loaded the animation is already half way through the playback.
Is there a signal or event in flutter that will let me know that the app has loaded?
In a widget you can use
WidgetsBinding.instance.addPostFrameCallback((_){
//stuff
})
If you put this in your initState the callback will be called after the first frame is rendered, if that's what you need.

Flutter Native SplashScreens Background processes

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...
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.

How can I fix the delay of flutter app during launch?

When I run flutter app it delays for few seconds shows just white screen and then the main page is shown. How can i fix it
There is an entry in the docs about the launch screen.
https://flutter.io/docs/development/ui/assets-and-images#updating-the-launch-screen
Basically you can provide an image to be shown while flutter loads. The framework is not ready at that point though, so this is done on the platform side.