Black screen on startup after updating flutter - flutter

I recently updated the flutter. For running flutter project I am using android via usb. And after updating every project on startup shows black screen. Previous version worked fine. I tried to change launch splash screen(drawable/launch_background.xml) in android to white but black screen shows after splash screen.
This is the simple code I am trying to run
void main()=> runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context){
return MaterialApp(
home:MyHomePage(),
);
}
}
So how can I remove black screen on startup?
The black screen like here.
As I said black screen shows after updating flutter to a new version. And I downgraded the flutter version to old and black screen disappeared.

I had the same problem when I switched to beta channel of flutter.
I noticed there is another launch_background.xml file in drawable-v21 folder.
so I copied the content of launch_background.xml in drawable folder to launch_background.xml in drawable-v21 and it worked.

If you see the black window background of the activity showing until Flutter renders its first frame you should add this on your AndroidManifest, between < activity> ... < /activity>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>

I had a black screen after splash Screen on iOS. I had a line like this in the Info.plist file in Runner:
<string>LaunchScreen.storyboard</string>
I changed this line like this:
<string>LaunchScreen</string>
and the black screen went away

The solution to this problem is quite easy. I have been facing this problem since months and now I came up with a solution.
Run this command in terminal
flutter config --no-enable-android-embedding-v2
And from next project you won't face such problem. But make sure that 'enable-android-embedding-v2' is set to 'false' by running command
flutter config
on terminal.
Thank You!

I had the same issue with my flutter project. It has a simple fix in the AndroidManifest.xml. Make sure that
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
Is above
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
In the AndroidManifest.xml

Related

How to use the flutter native splash screen

I am facing trouble using the flutter native splash screen.A blank screen appears when i tried to use the flutter_native_splash package https://pub.dev/packages/flutter_native_splash
You can create native splash screen for both (android, iOS) platform manually to follow the doc (https://docs.flutter.dev/development/ui/advanced/splash-screen) but I will recommend you to use flutter_native_splash plugin cause it will save your time and create less opportunity of mistakes.
Create a new assets and logos folder in your root project path and place your splash_screen_logo.png like this [project_name]/assets/logos/splash_screen_logo.png
Add flutter_native_splash: ^2.2.16 at dev_dependencies in pubspec.yaml (please replace ^2.2.16 version with the latest version number. Check it)
dev_dependencies:
flutter_test:
sdk: flutter
flutter_native_splash: ^2.2.16
Paste this below code in your pubspec.yaml and change the color and image asset path
flutter_native_splash:
color: "#071b5d"
image: assets/logos/splash_screen_logo.png
android: true
ios: true
Finally in your project path terminal, run this command: flutter pub run flutter_native_splash:create and it will generate native splash screen for both android and iOS.
The actual and perfect way is not to add a page or use a plugin, you can even do it natively by this method:
Go to => andoid > app > main > res > drawable > in this folder you can see a file called lauch_background open it,
<?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="fill"
android:src="#mipmap/ic_launcher" />
</item>
</layer-list>
add your image in the folder and rename the image file name to ic_launcher. Also uncomment the commented code in the file.
refer this example for you native splash screen
https://www.codegrepper.com/code-examples/whatever/flutter+native+splash+screen
Two Packages are Needed If you want to Add a Native Flutter Splash screen and Change App Icon using Easy Method
flutter_native_splash 2.2.16
flutter_launcher_icons
Flutter native splash screen and App icon change - Easy Method
this is the right code, the right indentation matters
flutter_native_splash: ^2.2.16
flutter_native_splash:
color: "#004ab9"
images: assets/finviobackground.png
android: true
ios: true

How to set a Flutter Custom Notification Icon ?,because there is no default notification icon in flutter for fcm

I want to set a custom notification icon to appear in my notifications panel for my flutter app when i use fcm(firebase cloud messaging) but there is only a grey circle that appears and no icon .
After Searching for a long time i finally found the answer and here it is:
Create a custom notification icon using this tool.
Paste the generated list of icons in android/app/src/main/res.
Go to your manifest android/app/src/main/AndroidManifest.xml and add the following meta data in the application (not activity) tag:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorPrimary" />
If you don't have a colors.xml in res/values, create one:
Done! It should work, let me know if it doesn't.
Discussion for the question is here.

Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated

I am new to flutter and recently tried to develop a test app for learning sake with latest version Flutter 2.5. By looking at some tutorial online, I have added flutter_native_splash: ^1.2.3 package for splash screen. And works fine.
However, when I launch app for the first time, it shows following debug message
W/FlutterActivityAndFragmentDelegate(18569): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
After visiting the above link, I am not able to understand much what is supposed to be done.
Code in pubspec.yaml
flutter_native_splash:
color: "#FFFFFF"
color_dark: "#000000"
image: assets/images/splash_720.png
android: true
ios: true
android12: true
Also, compileSdkVersion and targetSdkVersion is set to 31 in build.gradle
Please help. Thanks in advance.
To avoid that warning you just need to remove that API usage from your project.
Remove these lines of code from the AndroidManifest.xml file.
Previously, Android Flutter apps would either set io.flutter.embedding.android.SplashScreenDrawable in their application manifest, or implement provideSplashScreen within their Flutter Activity. This would be shown momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This is no longer needed and is deprecated – Flutter now automatically keeps the Android launch screen displayed until Flutter has drawn the first frame. Developers should instead remove the usage of these APIs. - source
UPDATE (FLUTTER 2.8.0)
As per the flutter 2.8.0 update, The newly created project doesn't have this warning.
They removed unused API from Androidmanifest.yml but still have belove mentioned code.
Remove the below lines from the android manifest file. It's no longer used
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"/>

Flutter splash screen not showing

I'am trying to add a splash screen on my application , i'am pretty sure i made all the steps correctly
I've added my picture on launch_background.xml
<?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/black"/>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/1-ZID-SplashScreen" />
</item>
</layer-list>
And i have added the path of the picture which is located on drawable folder on pubsec.yaml
flutter:
assets:
- assets/images/
- assets/google_fonts/
- android/app/src/main/res/drawable/
But still the splash screen stills white, help me resolve this please ^^
Thanks.
You can use flutter_native_splash it will help you achieve what you want
You can add a native splash screen to your app in 02 ways.
Using flutter package.
This is the easiest way to add a splash screen for your flutter app. (You don't need to have prior Native android & ios development knowledge).
Link to package:- package
This video shows that how to use this package:- video tutorial
Without using flutter package (Native way)
For this method, you needed to have prior native android & ios development experience.
If you had native development experience, you can use the below links to see the steps.
Link
As I know, the ressource name (in your case "android:src="#drawable/1-ZID-SplashScreen") should start with a letter not a number (google the android ressources naming convention for more information).

Flutter app shows a black screen before loading the app

I have noticed this problem with flutter apps, when I open a flutter app from cold boot, I see a black screen popping before the actual app is loaded. I have seen the problem with the Newsvoice production app and as well as with a test app I installed.
Check the video here: https://www.youtube.com/watch?v=zszud6UWzps
Is it a bug in the Flutter SDK?
This issue was fixed recently. If you are using a version of Flutter that has this engine fix, you won't see the black frame. (The fix should be on the Flutter master branch by now, but not the alpha branch.)
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/my_splash"
/>
AndroidManifest.xml check the FlutterActivity and add this code
It's not issue, this for hot reload. Don't worry about that. When you run with release, you can't see this.
if you want to be sure try ->
flutter run --release
It's not a bug. That's the way it behaves normally. You can replace the loading black screen with an image:
In AndroidManifest.xml, here is where you can change your splash image.
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background" />
Find the files:
android\app\src\main\res\drawable\launch_background.xml
android\app\src\main\res\drawable-v21\launch_background.xml
Change the files to add your own custom image:
<item>
<bitmap android:gravity="center" android:src="#drawable/splash_image" />
</item>
Your splash image should be stored in the drawable folders:
android\app\src\main\res\drawable\splash_image.png
app\src\main\res\drawable-v21\splash_image.png
I can solve this issue, after removing FutureBuilder when using Firebase. just initialize Firebase app on main() like this
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
instead of using FutureBuilder on your build method
The black screen is something which comes for a variety of reasons is what I have gathered from looking at different responses on the net. In my case I realized on thing, that my Firebase.initializeApp() was returning an error in the snapshot of my FutureBuilder due to which no widgets were being rendered. I tried everything to no avail. Finally I moved my project to a completely new folder as described here
and then my black screen issue got resolved.