The Flavors project is a Flutter application designed to explore and demonstrate the implementation of Flutter flavors for multi-company and multi-environment setups. This project specifically focuses on testing and experimenting with different configurations for Test, Preprod, and Production environments.
Flavors in Flutter allow you to build and deploy different instances of your application, each configured for a specific environment or company. This project aims to provide a template and examples for setting up flavors in a Flutter project and handling multiple environments such as testing, preproduction, and production.
Ensure that you have Flutter and Dart installed on your development machine. If not, please follow the official Flutter installation guide.
Clone the Flavors repository to your local machine:
bashCopy code
git clone https://github.com/your-username/flavors.git
Navigate to the project directory and install the required dependencies:
bashCopy code
cd flavors flutter pub get
Flavors are defined in the lib/config/flavors.dart
file. You can customize and add flavors to suit your multi-company setup.
class FlavorConfig {
static Flavor flavor = Flavor.PROD; // Change this to the desired flavor
}
enum Flavor {
TEST,
PREPROD,
PROD,
}
Environment-specific configurations can be found in the lib/config/environment.dart
file. Customize this file based on the requirements of your testing, preproduction, and production environments.
class EnvironmentConfig {
static String apiUrl = _getApiUrl();
static String _getApiUrl() {
switch (FlavorConfig.flavor) {
case Flavor.TEST:
return "https://api.test.com";
case Flavor.PREPROD:
return "https://api.preprod.com";
case Flavor.PROD:
return "https://api.prod.com";
default:
return "https://api.prod.com";
}
}
}
Run the app using the desired flavor:
bashCopy code
flutter run --flavor=prod
Replace prod
with test
or preprod
as needed.
Ensure that you thoroughly test each flavor in its respective environment to validate the configurations and behavior.
Contributions are welcome! Feel free to open issues, create pull requests, or suggest improvements.
This project is licensed under the MIT License.