सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
flutter_flavorizr एक विकासकर्ता टूल है जो Flutter एप्लिकेशन में ऐप फ्लेवर के निर्माण और प्रबंधन को सरल बनाता है। यह विभिन्न बिल्ड वेरिएंट—जैसे विकास, स्टेजिंग, और उत्पादन—की कॉन्फ़िगरेशन को स्वचालित करता है, जिसमें Android, iOS, और macOS के लिए प्लेटफॉर्म-विशिष्ट फ़ाइलें बनाई जाती हैं। न्यूनतम सेटअप के साथ, यह एप्लिकेशन नाम, पैकेज नाम, आइकन, और लॉन्च स्क्रीन जैसी वातावरण-विशिष्ट कॉन्फ़िगरेशन को सरल बनाता है। इससे हाथ से गलतियाँ कम होती हैं और विभिन्न वातावरणों में बिल्ड प्रक्रिया तेज हो जाती है।
उपयोग
कई ऐप पर्यावरण का प्रबंधन करना
बिल्ड कॉन्फ़िगरेशन को स्वचालित करना
फ्लेवर के अनुसार ऐप संसाधनों को कस्टमाइज़ करें
CI/CD पाइपलाइन को सुव्यवस्थित करना
विभिन्न बिल्ड पर टीम सहयोग का समर्थन करना
मुख्य विशेषताएँ
ऑटो-जनरेट एंड्रॉइड, आईओएस, और मैकओएस कॉन्फ़िग फ़ाइलें
स्वाद के अनुसार कस्टम ऐप नाम और पैकेज नाम समर्थित हैं
मौजूदा Flutter प्रोजेक्ट्स के साथ एकीकरण
YAML फ़ाइल के माध्यम से कॉन्फ़िगरेबल
फ्लेवर के अनुसार आइकन और लॉन्च स्क्रीन
इनके लिए उपयुक्त
कई ऐप फ्लेवर का उपयोग करने वाली Flutter टीमें
परिवेश-विशिष्ट निर्माण की आवश्यकता वाले प्रोजेक्ट
अलग-अलग डेप्लॉयमेंट स्टेज वाले CI/CD वर्कफ़्लो
हस्तक्षेप से कॉन्फ़िगरेशन को कम करने वाले डेवलपर्स
विचार योग्य बातें
Flutter फ्लेवर अवधारणाओं के समझ की आवश्यकता है
हाथ से संपादित कॉन्फ़िग फ़ाइल्स के साथ टकराव हो सकता है
त्रुटियों से बचने के लिए सही YAML कॉन्फ़िगरेशन की आवश्यकता होती है
प्रोजेक्ट लाइफसाइकिल के शुरुआती चरण में सबसे अच्छा उपयोग किया जाता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Flutter Flavorizr
A flutter utility to easily create flavors in your flutter application
If you want to support this project, please leave a star, share this project, or consider donating through Github Sponsor.
Getting Started
Let's start by setting up our environment in order to run Flutter Flavorizr
Prerequisites
Side note: this tool works better on a new and clean Flutter project.
Since some processors reference some existing files and a specific base structure, it could be possible that running Flutter Flavorizr over an existing project could throw errors.
Installation
This package is intended to support development of Flutter projects. In general, put it under dev_dependencies, in your pubspec.yaml:
dev_dependencies:flutter_flavorizr:^2.6.0
You can install packages from the command line:
pub get
Create your flavors
Once you have added flutter_flavorizr as a dev dependency, you have to edit your pubspec.yaml and define the flavors.
Example
Create a new file named flavorizr.yaml and define the name of the flavors, in our example apple and banana. For each flavor you have to specify the app name, the applicationId and the bundleId.
Alternatively, add a new key named flavorizr and define a sub item named flavors.
Under the flavors array you can define the name of the flavors, in our example apple and banana. For each flavor you have to specify the app name, the applicationId and the bundleId.
This way of defining flavors will be deprecated in versions 3.x
flavors:apple:app:name:"Apple App"android:applicationId:"com.example.apple"buildConfigFields:field_one:type:"String"value:"example field one"field_two:type:"char"value:"y"field_three:type:"double"value:"20.0"ios:bundleId:"com.example.apple"
variable (for iOS and macOS)
key
type
default
required
description
target
String
false
The type of the target (debug, release, profile). Do not specify a target if you want to apply it to all of them.
The type of the target (debug, release, profile). Do not specify a target if you want to apply it to all of them.
optional
bool
false
false
If true, uses #include? — the build will not fail if the file is missing. Defaults to false (#include).
Global includes (under app.ios or app.macos) are merged with flavor-specific includes. Global entries come first; flavor entries are appended and take precedence for any duplicate keys.
flavorizr:app:ios:includes:-value:"Shared/base.xcconfig"# applied to all targets-value:"Shared/debug.xcconfig"target:debug# applied to debug onlyflavors:apple:app:name:"Apple App"android:applicationId:"com.example.apple"ios:bundleId:"com.example.apple"includes:-value:"Apple/flavor.xcconfig"-value:"Apple/optional.xcconfig"optional:true# → #include? "Apple/optional.xcconfig"-value:"Apple/release.xcconfig"target:release
customConfig (for Android only)
You can define any custom property for android
flavors:apple:app:name:"Apple App"android:applicationId:"com.example.apple"customConfig:versionNameSuffix:"\"-green-prod\""# Don't forget to escape strings with \"signingConfig:flavorSigning.greenversionCode:1000minSdkVersion:23# ..... and any custom property you want to add
This .yml part, generate this custom android flavor:
monochrome (Themed icons on Android >= 13) is optional.
After removing adaptiveIcon key, the adaptive icons generated before will still exist. Please delete adaptiveIcon manually.
Usage
When you finished defining the flavorizr configuration, you can proceed by running the script with:
flutter pub run flutter_flavorizr
You can also run flutter_flavorizr with a custom set of processors by appending the -p (or --processors) param followed by the processor names separated by comma:
flutter pub run flutter_flavorizr -p <processor_1>,<processor_2>
Example
flutter pub run flutter_flavorizr -p assets:download
flutter pub run flutter_flavorizr -p assets:download,assets:extract
Keep in mind that the order of the processors is important. For example, if you want to run the assets:extract processor, you must run it after the assets:download processor.
Also, some processors need assets to be downloaded before running. For example, the android:dummyAssets processor needs the assets:download processor to be run before.
As a rule of thumb, you should always run both assets:download and assets:extract before running any other processor.
If you want to run flutter_flavorizr in verbose mode, you can append the -v (or --verbose) param:
flutter pub run flutter_flavorizr -v
This will print all the logs to the console, including the ones from the processors.
If you want to skip the confirmation step, you can append the -f (or --force) param:
flutter pub run flutter_flavorizr -f
Run your flavors
Once the process has generated the flavors, you can run them by typing
flutter run --flavor <flavorName>
Example
flutter run --flavor apple
flutter run --flavor banana
Currently, due to a bug in the Flutter SDK, it's not possible to run the macOS flavors from the terminal.
You can run them from XCode by selecting the proper schema and by pressing play.
As a temporary workaround, you can apply the following configuration to your flavorizr config:
By default, when you do not specify a custom set of processors by appending the -p (or --processors) param, a default processors set will be used:
assets:download
assets:extract
android:androidManifest
android:flavorizrGradle
android:buildGradle
android:dummyAssets
android:icons
flutter:flavors
flutter:app
flutter:pages
flutter:main
ios:podfile
ios:xcconfig
ios:buildTargets
ios:schema
ios:dummyAssets
ios:icons
ios:plist
ios:launchScreen
macos:podfile
macos:xcconfig
macos:configs
macos:buildTargets
macos:schema
macos:dummyAssets
macos:icons
macos:plist
linux:cmake
linux:runnerCmake
linux:myApplication
windows:mainCppTemplate
windows:runnerRcTemplate
windows:cmake
windows:dummyAssets
windows:icons
google:firebase
huawei:agconnect
assets:clean
ide:config
Customize your app
Flutter_flavorizr creates different dart files in the lib folder. In the flavors.dart file we have the F class which contains all of our customizations.
The process creates a simple title customization: a switch which checks the current appFlavor (defined in our app starting point) and returns the correct value. Here you can write whatever you want, you can create your custom app color palette, differentiate the URL action of a button, and so on.
If you are wondering how to use these getters, you can find an example under the pages folder: in the my_home_page.dart file, the page shown after the launch of the app, we can see a clear reference on the title getter defined in the F class.
Third party services
Google Firebase
In order to flavorize your project and enable Firebase in your flavor you have to define a firebase object below each OS flavor. Under the firebase object you must define the config path of the google-services.json (if you are under Android configuration) or GoogleService-Info.plist (if you are under iOS or macOS configuration).
As you can see in the example below, we added the path accordingly
After running flutter_flavorizr, remember to add the native dependencies for the targeted operative system. You can take advantage of flutterfire_cli to do so. Remember to ignore the generated firebase_options.dart file, as it will conflict with the flavors configuration. Do this instead:
import'package:firebase_core/firebase_core.dart';
import'package:firebase_crashlytics/firebase_crashlytics.dart';
import'package:flutter/foundation.dart';
import'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
awaitFirebase.initializeApp(); // Do not pass the options hererunApp(constApp());
}
Huawei AppGallery Connect
In order to flavorize your project and enable AppGallery Connect in your flavor you have to define an agconnect object below each Android flavor. Under the agconnect object you must define the config path of the agconnect-services.json.
As you can see in the example below, we added the path accordingly
Remember to add the native dependencies for the targeted operative system for both Firebase and Huawei AppGallery Connect: flutter_flavorizr will only take care of applying the configuration.
Let the user define its custom set of available instructions.
Questions and bugs
Please feel free to submit new issues if you encounter problems while using this library.
If you need help with the use of the library or you just want to request new features, please use the Discussions section of the repository. Issues opened as questions will be automatically closed.
License
Flutter Flavorizr is available under the MIT license. See the LICENSE file for more info.