skip to Main Content

Is there any way for me to create different splash screen for multiple flavor in flutter?

2

Answers


  1. on main.dart

    import 'dart:io';
    
    Widget splashScreen = DefaultSplash();
    void main() async {
     ...
     if (Platform.isIOS) {
       splashScreen = SplashScreenIOS();
     } else if (Platform.isAndroid) {
       splashScreen = SplashScreenAndroid();
     }
     ...
    }
    

    then in MyApp class

    MaterialApp(
     home : splashScreen
    )
    
    Login or Signup to reply.
  2. I’ll try to edit later for Android, but as for the iOS, here’s the process.

    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    

    That’s how your LaunchScreen is defined in Info.plist.

    Open XCode, add User-Defined Setting.

    enter image description here

    By opening the build settings and clicking the tiny + button.

    enter image description here

    Add a variable, like LAUNCH_SCREEN.

    Now we will create another LaunchScreen, by creating new LaunchScreen, like called LaunchScreenFlavor2.

    enter image description here

    enter image description here

    Once you create the new launch screen, and assign LAUNCH_SCREEN variable to that storyboards, scroll to the beginning of my answer, and give the variable in Info.plist. Like:

    <key>UILaunchStoryboardName</key>
    <string>${LAUNCH_SCREEN}</string>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search