Splash Screen Setup

Dimensions

OLD Not sure this is still valid as per native splash implementation

Android Image Dimensions

For Android, you should provide images for different density buckets. Here are the recommended dimensions for each density:

  • mdpi (baseline): 1x, Dimensions: Original size (e.g., 320x480 for a full-screen image)
  • hdpi: 1.5x, Dimensions: 1.5 times the mdpi size (e.g., 480x720 for a full-screen image)
  • xhdpi: 2x, Dimensions: 2 times the mdpi size (e.g., 640x960 for a full-screen image)
  • xxhdpi: 3x, Dimensions: 3 times the mdpi size (e.g., 960x1440 for a full-screen image)
  • xxxhdpi: 4x, Dimensions: 4 times the mdpi size (e.g., 1280x1920 for a full-screen image)

iOS Image Dimensions

For iOS, you should provide images for different scale factors. Here are the recommended dimensions for each scale factor:

  • 1x: Original size (e.g., 320x480 for a full-screen image)
  • 2x: 2 times the original size (e.g., 640x960 for a full-screen image)
  • 3x: 3 times the original size (e.g., 960x1440 for a full-screen image)

Example Dimensions for a Full-Screen Image

Assuming the original image size is 320x480 (mdpi or 1x):

  • Android:

    • mdpi: 320x480
    • hdpi: 480x720
    • xhdpi: 640x960
    • xxhdpi: 960x1440
    • xxxhdpi: 1280x1920
  • iOS:

    • 1x: 320x480
    • 2x: 640x960
    • 3x: 960x1440

Directory Structure

Ensure that you place the images in the correct directories:

Android

  • android/app/src/main/res/drawable-mdpi/splash_image.webp
  • android/app/src/main/res/drawable-hdpi/splash_image.webp
  • android/app/src/main/res/drawable-xhdpi/splash_image.webp
  • android/app/src/main/res/drawable-xxhdpi/splash_image.webp
  • android/app/src/main/res/drawable-xxxhdpi/splash_image.webp

iOS

  • ios/Runner/Assets.xcassets/LaunchImage.imageset/splash_image@1x.webp
  • ios/Runner/Assets.xcassets/LaunchImage.imageset/splash_image@2x.webp
  • ios/Runner/Assets.xcassets/LaunchImage.imageset/splash_image@3x.webp

Additional Configuration for Native Splash Screens

To provide a native splash screen that displays before the Flutter framework is initialized, you need to configure the native splash screens for both Android and iOS.

Android Configuration

  1. Update android/app/src/main/res/drawable/launch_background.xml: Create or update the launch_background.xml file to include your webp image:

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <bitmap
                android:gravity="center"
                android:src="@drawable/splash_image" />
        </item>
    </layer-list>
    
  2. Update android/app/src/main/res/values/styles.xml: Ensure that the styles.xml file includes the splash screen theme:

    <style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    
  3. Update AndroidManifest.xml: Set the splash screen theme in the AndroidManifest.xml file:

    <application
        android:label="your_app_name"
        android:icon="@mipmap/ic_launcher"
        android:theme="@style/LaunchTheme">
        <!-- Other configurations -->
    </application>
    

iOS Configuration

  1. Update ios/Runner/Assets.xcassets/LaunchImage.imageset: Add your webp image to the LaunchImage.imageset directory.

  2. Update ios/Runner/Info.plist: Ensure that the Info.plist file includes the splash screen configuration:

    <key>UILaunchImages</key>
    <array>
        <dict>
            <key>UILaunchImageMinimumOSVersion</key>
            <string>8.0</string>
            <key>UILaunchImageName</key>
            <string>LaunchImage</string>
            <key>UILaunchImageOrientation</key>
            <string>Portrait</string>
            <key>UILaunchImageSize</key>
            <string>{320, 480}</string>
        </dict>
        <dict>
            <key>UILaunchImageMinimumOSVersion</key>
            <string>8.0</string>
            <key>UILaunchImageName</key>
            <string>LaunchImage2@</string>
            <key>UILaunchImageOrientation</key>
            <string>Portrait</string>
            <key>UILaunchImageSize</key>
            <string>{640, 960}</string>
        </dict>
        <dict>
            <key>UILaunchImageMinimumOSVersion</key>
            <string>8.0</string>
            <key>UILaunchImageName</key>
            <string>LaunchImage2@</string>
            <key>UILaunchImageOrientation</key>
            <string>Portrait</string>
            <key>UILaunchImageSize</key>
            <string>{960, 1440}</string>
        </dict>
    </array>