From what I can tell, Flutter doesn’t have the ability to set true runtime environment variables. What Flutter calls environment variables seem to be nothing more than build arguments. I would be happy to be proven wrong on this.
For example, you can pass in environment variables (build args) like so: flutter build web --dart-define MY_ENV_VAR=foobar
. I don’t see how I can pass in a change to an environment variable after flutter build web
, however.
This makes dockerizing a Flutter web app with runtime environment variables impossible. If flutter build web --dart-define MY_ENV_VAR=foobar
is in my dockerfile, then the environment variables are baked into the image.
So is there a way to do docker run -p 80:80 -e MY_ENV_VAR=foobar my-web-app
?