Reputation: 774
Why does my Flutter app show a white screen for few seconds on start? How do I solve this issue?
Upvotes: 60
Views: 83722
Reputation: 1
I know it's too late, but I want to share my problem and solution.
In my problem, it happened because my build.gradle file was changed on the namespace and applicationId. This can cause the Flutter app to show a white screen for a few seconds on startup, and the app may not launch.
For an Example your original namespace and applicationID is
com.example.original
but it is change into
com.example.testing
To resolve this change it back into the original one
Upvotes: 0
Reputation: 1058
You can use the package flutter_native_splash to add native splash screens for Android and iOS without the manual changes described in other answers.
The package does the manual changes for you.
1 - Depend on it:
dev_dependencies:
flutter_native_splash: ^0.1.4
And flutter pub get
2 - Configure your splash screen on pubspec.yaml
:
flutter_native_splash:
image: assets/images/splash.png
color: 42a5f5
3 - Run the package
flutter pub run flutter_native_splash:create
Splash screens are now generated.
Upvotes: 24
Reputation: 21
Open Android folder and in drawable folder replace your image
In manifest file there is some code Just uncomment it and do as following.
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable
android:resource="@drawable/launch_background"
/>
Happy coading
Upvotes: 1
Reputation: 62419
If you are creating new projects right now, they gave the solution (with commented code in launch_background.xml)
Just open the following files through the android directory.
You will see the following commented code:
Just uncomment it and do as following, You can replace your own image by changing drawable name:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
Hope it will be helpful.
Upvotes: 1
Reputation: 601
I were setting proxy right in flutter.bat file. And it was setting proxy for local machine too. So my ABD can't listen the physical device.
So if you have similar case - try to set no_proxy for local zones or remove proxy at all.
Upvotes: 0
Reputation: 1
I head the same problem. Even after I added splash screen I got the black screen for the first time loading the app. My solution was to change the flutter channel form stable to beta. To do that open a command prompt
Check what channel you are currently on
flutter channel
To change the channel type
flutter channel [channel name]
After that type
flutter upgrade
That's what helped me. I hope it helps also someone.
I found the solution here: https://github.com/flutter/flutter/issues/37155
Upvotes: -2
Reputation: 2381
I had this problem after I had already added in a splash screen. I was getting a white screen as well. It turns out you have to reinstall the app to get rid of any caching and then it should work properly
https://docs.nativescript.org/tooling/publishing/creating-launch-screens-ios
I hope this helps someone else!
Upvotes: 0
Reputation: 1261
If you see the black window background of the activity showing until Flutter renders its first frame, add this on your AndroidManifest, between < activity> ... < /activity>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
Upvotes: 23
Reputation: 404
Among the files generated with the flutter create command. A splash screen is generated to be shown before the first frame when flutter is rendering widgets to screen. You can modify it to show a custom splash screen of your choice or you can just remove it..
Within the android folder, open up the AndroidManifest.xml file.
There you can remove the meta-data with attribute name ..SplashScreenUntilFirstFrame tag within activity named .MainActivity
You can check the drawables folder and styles.xml file to modify the splash screen if you want to keep it.
Within these folders there are also comments that explain more..
Upvotes: 1
Reputation: 4810
Android - Now you can change in
/AndroidStudioProjects/vendowallet/android/app/src/main/res/drawable/launch_background.xml
Something like
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/ic_launcher" />
</item>
IOS
Change the LaunchImage in Assets.xcassets
Upvotes: 6