How to use the flutter native splash screen - flutter

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

Related

I am using flutter native splash package for splash screen in my app

It is working properly in all devices including web except android 12 devices. I tried too many ways to figure it out, but am not able to find solution. If anyone knows solution please reply as soon as possible.
The problem is in android 12 devices, logo which I have used isn't showing.In other devices it working perfectly.
Here I am attaching my pubspec.yaml dev_dependencies info:-
dev_dependencies:
flutter_test:
sdk: flutter
flutter_native_splash: ^2.2.3+1
flutter_lints: ^2.0.0
flutter_native_splash:
image: assets/images/splash.png
color: "#23AA49"
android: true
android12: true
ios: true
android_12:
image: assets/images/splash.png
color: "#23AA49"
Apps targeting Android 12 and higher are required to specify an explicit value for android:exported
Make these changes
android:exported="true"
Update targetSdkVersion and compileSdkVersion
you can refer to this
https://developer.android.com/about/versions/12/migration
Hope this helps you
enter image description hereFollow this picture you can see build.gradle file go there and then follow second picture
search this potion of file and modified it as per my screenshot
then in same file modified this line also
Go to Your android->app when you noticed that build.gradle file just open it and. modify it it contains targetsdkversion and compilesdkversion aslo
click on this link you will show one image then modify your puspec.yamel file i have no such reputation so i can not embeded image in post right now after 10 i get that right so you have to click on this link

What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'

How to use custom icon in flutter, using android studio! I need to know what we want to do in pubspec.yaml. Because I got an error in pubspec.yaml, cant view a icon in our program.
It can help if you specify what sort of icon you are trying to add, and if you share some of your pubspec file. Are we talking about an app icon (using a package like flutter_launcher_icons) or icons to use within the app (like the ones created via fluttericon.com).
I'll assume you're talking about launcher icons.
First make sure you have the package:
https://pub.dev/packages/flutter_launcher_icons
In the root of your pubspec.yaml file, you can add lines like:
flutter_icons:
android: true
ios: true
image_path: "assets/myIcon.png"
adaptive_icon_background: "#ffffff"
adaptive_icon_foreground: "assets/myIconForeground.png"
This will use myIcon.png for the iOS app, and apply the foreground image on a white background for Android (where depending on your phone, a circular or square icon can be used).
Now you may notice the asset paths, you can also add the icons as assets to your app such that you can use them elsewhere.
flutter:
...
assets:
- assets/myIcon.png
- assets/myIconForeground.png
After which you should be able to run the plugin and generate your native icons:
flutter pub run flutter_launcher_icons:main

How can I change the name and the logo of google_sign_in with flutter?

I'm using google_sign_in + firebase to authenticate users via their google accounts in my flutter application.
I don't want my users to see the panel like the image below:
(It has the flutter logo and my project name! But I want to put the app logo and a customized name instead.)
Image:
Based on the provided image in your question there is no way to edit the icon and name of the application manually or by code in the mentioned screenshot, the only way is to change the entire project icon and project name which is guided as follows.
To change project name on Android
Open AndroidManifest.xml (located at android/app/src/main)
<application
android:label="App Name" ...> // Your app name here
To change project name on iOS
Open info.plist (located at ios/Runner)
<key>CFBundleName</key>
<string>App Name</string> // Your app name here
Don't forget to run
flutter clean
To change the project icon use the following flutter plugin or watch this youtube video
flutter_launcher_icons

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