You can add the --dart-define=
in you flutter run
command
Like this
flutter run --dart-define=environment="QA"
Now access the variable in the dart file
const environment =
String.fromEnvironment('environment', defaultValue: 'Testing');
if you are using flavours you can use this command
flutter run --flavor core_app -t lib/core_app.dart --dart-define=environment="QA"
Thanks
Top comments (2)
Didn't worked for me
flutter doctor
--dart-define
is not working returning empty value as mentioned above --dart-define got reverted github.com/flutter/flutter/pull/52041 and I also could not get it to workthat's help but how to pass args using command line for flutter web