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.
2
This is probably a weird gotcha with String.fromEnvironment, from the docs:
String.fromEnvironment
This constructor is only guaranteed to work when invoked as const
So this only works if you use
const String.fromEnvironment('ENVIRONMENT', defaultValue: "DEV");
change this
--dart-define=ENVIRONMENT=PROD
to this
--dart-define ENVIRONMENT=PROD
Click here to cancel reply.
2
Answers
This is probably a weird gotcha with
String.fromEnvironment
, from the docs:So this only works if you use
change this
to this