To support multiple environments (e.g., production, development), you can create separate configuration files for each flavor using the pattern flutter_native_splash-<flavor>.yaml.
1. Setup Configuration Files
Create a file for each flavor in your project root. For example, flutter_native_splash-development.yaml:
flutter_native_splash:
color: "#ffffff"
image: assets/logo-development.png
branding: assets/branding-development.png
color_dark: "#121212"
image_dark: assets/logo-development.png
branding_dark: assets/branding-development.png
android_12:
image: assets/logo-development.png
icon_background_color: "#ffffff"
image_dark: assets/logo-development.png
icon_background_color_dark: "#121212"
web: false
2. Generate Splash Screens
Use the CLI to generate screens for specific flavors or all of them at once.
Generate a single flavor:
dart run flutter_native_splash:create --flavor <flavor_name>
Generate multiple specific flavors:
dart run flutter_native_splash:create --flavors development,staging,production
Generate all flavors automatically:
This command scans for all flutter_native_splash-*.yaml files and generates them.
dart run flutter_native_splash:create --all-flavors
# OR
dart run flutter_native_splash:create -A
3. Platform Specific Setup
Android
No additional setup is required as long as your flavor names match your config file suffixes.
iOS
Since iOS requires manual linking of Storyboards for different schemes:
- Open
Runner.xcworkspace in Xcode. - Locate the new Storyboard files in
{project root}/ios/Runner/Base.lproj. - Drag and drop them into the Xcode project navigator (next to
LaunchScreen.storyboard), selecting 'Copy if needed'. - In the Runner target -> Build Settings -> All/Combined:
- Add a User-Defined Setting named
LAUNCH_SCREEN_STORYBOARD. - For each flavor/scheme, enter the exact name of the generated Storyboard (e.g.,
LaunchScreenDevelopment).
- In your
Info.plist, find 'Launch screen interface file base name' and change its value to $(LAUNCH_SCREEN_STORYBOARD).
dart run flutter_native_splash:create --all-flavors