Questions tagged [dart-define]
9 questions
4
votes
2 answers
Flutter android studio --dart-define not working
I am trying to pass arguments using --dart-define in the Android Studio IDE, but I am not able to access in the code.
code is
String.fromEnvironment('ENVIRONMENT', defaultValue: "DEV");
It is returning defaultValue.

Naveed Jamali
- 748
- 8
- 14
3
votes
0 answers
Is there a way to use Flutter Flavors and use that mechanism to set the --dart-define variables
With Flutter I use -dart-define in order set some environment variables for different API's I use in the flutter app. And I am able to retrieve them using String.fromEnvironment.
I also use Flavors in order to set different App icons for both IOS…

Mau
- 63
- 3
2
votes
1 answer
How to use dart defined variables inside of AppDelegate.swift file
I am using Google Maps for Flutter to access a map in my application. To make it usable for iOS I need to provide the API key inside of AppDelegate.swift as:
GMSServices.provideAPIKey(GOOGLE_MAPS_API_KEY)
My application will be deployed later, so I…

coolerneo
- 21
- 2
2
votes
1 answer
Android Studio - multi-line additionalArgs?
I'm trying to build a Flutter app in Android Studio. We're using VSCode with quite many dart-define's in .vscode\launch.json. In Android Studio, I think, we should use Build Configuration - Additional run args.
The problem with it, however, is that…

Anton Duzenko
- 2,366
- 1
- 21
- 26
1
vote
0 answers
Flutter flavors deprecation
I am working on a project for a client and deciding on whether to use flavors or dart-define for environment config.
I like that flavors is built into the framework and there's a lot of documentation on how to get it working.
Is there a move away…

user2862281
- 11
- 1
0
votes
1 answer
Google Play Store does not see dart define variable
I have a silly question about dart define and Google Play Store configuration. After upload the version of the app variables from dart define from file does not work at all. What should I do make it run?
I have config.json file with keys. I've…

artex
- 3
- 1
0
votes
1 answer
flutter dart-define not loading on first build, only on hot restart
Hi,
Im setting flavor for my existing app and encountered an error with String.fromEnvironment.
It only get the right flavor when I click "Hot Restart"
Im using Flutter 3.7.10
Here are my flutter doctor -v logs:
Doctor summary (to see all…

Tùng Ng Thanh
- 11
- 2
0
votes
0 answers
Flutter Build IPA dart defines does not work properly
I am trying to build the ipa of an application, but I am faced an issue.
I need to pass few extra dart-defines
Example build:
flutter build ipa --dart-define=env=DEV --dart-define=host=https://api.dev-example.com
It does not do anything...
When I…

Prodromos Sarakinou
- 809
- 4
- 16
0
votes
0 answers
Adding calculated variable to --dart-define in Flutter
How can I add the calculated variable to --dart-define?
I want to run this:
flutter run --dart-define=githash=$(git rev-parse HEAD)
But it is not working. Appreciate if someone can advise. Thank you in advance!

Cengiz Gumus
- 41
- 5