A new Flutter project.
Run and define your:
API_KEY_ID
string valueSOME_CONDITIONS_PATH
string valueIS_STAGE
bool valueIS_PROD
bool value
You have 2 options to run:
flutter run --dart-define=API_KEY_ID=SOME_KEY --dart-define=SOME_CONDITIONS_PATH=/_path --dart-define=IS_STAGE=true --dart-define=IS_PROD=false
--dart-define-from-file=keys_production.json
or --dart-define-from-file=keys_staging.json
Useful links:
-
https://codewithandrea.com/articles/flutter-api-keys-dart-define-env-files/
-
https://thiele.dev/blog/part-1-configure-a-flutter-app-with-dart-define-environment-variable/
-
https://thiele.dev/blog/flutter-dart-define-part-2-dev-and-prod-package-names-and-bundle-ids/
- Configure CI/CD pipeline with dart define command and not show-off the API keys
- Add to
.gitignore
all json files with sensitiveAPI_KEYS
- Always remember to obfuscate code with sensitive
API_KEYS