Skip to content

Environmental Variable Issue #2671

Closed Answered by dam-ease
VikasAgrawal-04 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @VikasAgrawal-04.
I see you are trying to access the Environment Variables in your codebase.

One way to do this is:

  • Add your environment variables to Codemagic UI as you have done in screenshots you shared
  • When building the flutter app, add --dart-define to your scripts. E.g --dart-define=NAME=$NAME
  • You can now access these variables in your code with String.fromEnvironment method. Example: String.fromEnvironment('NAME')

You can also checkout this for more ways of handling environment variables. Please let me know if this helps.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dam-ease
Comment options

Answer selected by dam-ease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants