-
Notifications
You must be signed in to change notification settings - Fork 1
Flavors
Jimmy edited this page Mar 11, 2024
·
4 revisions
Flavors allow you to create different versions of your Flutter app with separate configurations, including different Firebase setups. This guide will how to change enviroment firebase to your firebase project. This repo is available for staging
and development
.if your project has another requirement, you can create a new environment and read in document
- Flutter SDK installed on your machine
- A Firebase project for each flavor you want to set up
NOTE: Each firebase project corresponds to an environment, please repeat this step
- Install Firebase FlutterFire CLI
- Use the FlutterFire CLI to generate the correct Dart initialization file for each Flutter flavor, with this command:
flutterfire config \
--project={YOUR_FIREBASE_ID_PROJECT} \
--out={part to save firebase_options.dart} \
--ios-bundle-id={BUNDLE_ID_APP} \
--android-app-id={APP_ID}
Example in repo:
flutterfire config \
--project=template-app-prod-3a034 \
--out=lib/firebase_options/firebase_options_prod.dart \
--ios-bundle-id=com.pingak9.template \
--android-app-id=com.pingak9.template
- With
google-services.json
andGoogleService-Info.plist
created from flutterfire, we will move it to follow step 2 and 3 corresponds to the environment
- Get
google-services.json
in your Firebase (If you have file from step 1, you can skip this step)
- Open the Project setting on your Firebase project
- Scroll to
Your apps
section - Press android app and press download
google-services.json
- For each
google-services.json
with the environment, add the path
android/app/src
|- production/google-services.json
|- staging/google-services.json
- Get
google-services.json
in your Firebase (If you have file from step 1, you can skip this step)
- Open the Project setting on your Firebase project
- Scroll to
Your apps
section - Press apples app and press download
GoogleService-Info.plist
- For each
GoogleService-Info.plist
with the environment, add the path
ios/config
|- production/GoogleService-Info.plist
|- staging/GoogleService-Info.plist
- Open the file with the path
android/app/src/build.gradle
- Look for this code and change name app follow your project
flavorDimensions "flavor"
productFlavors {
production {
dimension "flavor"
applicationIdSuffix ""
manifestPlaceholders = [appName: "Template"] // Change "Template" to your name app product
}
staging {
dimension "flavor"
applicationIdSuffix ".stg"
manifestPlaceholders = [appName: "Template [STG]"] // Change "Template [STG]" to your name app staging
}
}
- Open XCode from your project
- Select your target then “Build Settings” and search
APP_DISPLAY_NAME
- Change to the name you want