skip to Main Content

I’m setting up native splash screen in flutter.

Problem :

I want to delete Flutter icon when app loads (on native level).

app

My AndroidManifest.xml :

  <application
      android:label="@string/app_name"
      android:name="${applicationName}"
      android:icon="@mipmap/ic_launcher">

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
      ...

My styles.xml :

<resources>
    <style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@color/splash_background</item>
    </style>

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...

My colors.xml :

<resources>
    <color name="splash_background">#FFC0CB</color>
</resources>

2

Answers


  1. Chosen as BEST ANSWER

    Solution: You need to comment out this line in AndroidManifest.xml file.

    <application
          android:label="@string/app_name"
          android:name="${applicationName}">
          <!-- android:icon="@mipmap/ic_launcher"> -->
    
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
          ...
    

    And after you need to reload flutter dependencies:

    flutter clean
    flutter pub get
    

  2. Removing the Native Splash Screen in Flutter

    Understanding the Problem:
    Flutter applications typically use a native splash screen for initial loading times. If you want to remove this and replace it with a custom Flutter splash screen or eliminate it entirely, here’s how:

    Method 1: Using flutter_native_splash Package (Recommended)

    If you’ve used the flutter_native_splash package to generate your native splash screen, you can remove it using the following steps:

    1. Remove the package:
      • Open your pubspec.yaml file and remove the flutter_native_splash dependency.
    2. Run the removal command:
      • Open your terminal and navigate to your Flutter project directory.
      • Run the command flutter pub run flutter_native_splash:remove.
    3. Clean your project:
      • Run flutter clean to ensure all generated files are removed.

    Method 2: Manual Removal (Android)

    If you haven’t used a package, you can manually remove the native splash screen for Android:

    1. Delete the launch background:

      • Go to android/app/src/main/res/drawable and delete the launch_background.xml file.
    2. Create a blank style:

      • Create a new XML file named splash_screen.xml in the same directory with the following content:
      <resources>
          <style name="SplashScreenTheme" parent="Theme.AppCompat.NoActionBar">
              <item name="android:windowBackground">@android:color/transparent</item>
          </style>
      </resources>
      
    3. Apply the style:

      • Open AndroidManifest.xml and add the following line to the <application> tag:
      android:theme="@style/SplashScreenTheme"
      

    Method 3: Manual Removal (iOS)

    For iOS, you can remove the launch screen by:

    1. Delete the launch screen:
      • Delete the LaunchScreen.storyboard file from your Xcode project.
    2. Modify the info.plist:
      • Open ios/Runner/Info.plist and remove the UILaunchStoryboardName key.

    Important Considerations:

    • Custom Splash Screen: If you want to display a custom splash screen while your Flutter app loads, consider using a Flutter-based solution like a SplashScreen widget or a dedicated package.
    • Blank Screen: Removing the native splash screen might result in a blank screen while your app initializes. You can customize this behavior using platform-specific configurations or Flutter’s loading indicators.

    By following these steps, you can effectively remove the native splash screen from your Flutter application and customize the initial loading experience as needed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search