Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter build/run should be able to accept compile-time arguments #26638

Open
c16a opened this issue Jan 16, 2019 · 3 comments

Comments

@c16a
Copy link

commented Jan 16, 2019

Consider the below scenario.

I am developing a global application with strikingly different feature sets across countries. So it is no more sensible to package all features into one app and enable or disable (with a flag, say) at runtime, as this would bloat up the app rapidly.

Also while development, I have my development, staging and production environments for which I would need to package and distribute the apps appropriately.

Something along the lines of the following would make sense

country=US env=DEV flutter build apk
country=UK env=STAGING flutter build ios

Currently, the multiple entry point approach suggested in #18377 (comment) won't scale when you have increasing number of dimensions (similar to a build matrix in CI/CD systems)

Are there any plans of implementing this? It is obvious that Flutter already supports having build-time flags (like --release etc). I have never contributed to Flutter as such (an avid user, though), but if add support for custom flags is something I can take up, I can do it.

@zoechi

This comment has been minimized.

Copy link
Contributor

commented Jan 16, 2019

Sounds like you are looking for flavors
https://flutter.io/docs/deployment/flavors

Support is not perfect yet but usable with some tweaking here and there.

@c16a

This comment has been minimized.

Copy link
Author

commented Jan 16, 2019

I am looking for a more "pure Dart" approach to doing this. I've come across the flavoring articles you that page mentions, and both of them require some tinkering with Xcode schemas and Android Gradle flavors.

I don't honestly think this is something that even needs to be offloaded to iOS and Android configurations.

country=US env=DEV flutter build apk
country=UK env=STAGING flutter build ios

We'll need to have a way to make them accessible to the Dart byte code.

The below works on DartVM (server side Dart), but would obviously not work when the app is deployed on iOS or Android.

var country = const System.fromEnvironment("country", default: "US")

Currently, achieving this would require a context switch from the Dart experience, go backward in time, deal with the Xcode/AndroidStudio hoolapalooza.

@wintersandroid

This comment has been minimized.

Copy link

commented Jun 23, 2019

What we need is something like the androids "BuildConfig" class which can be set from the command line or/and from the pubspec.yaml. I would be keen on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.