flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.79k stars 3.2k forks source link

Explain the `--dart-define` option for `flutter` #4215

Open TatsuUkraine opened 4 years ago

TatsuUkraine commented 4 years ago

Flutter 1.17 added support for custom compile-time variables in flutter tools with --dart-define

Quite interesting feature not just in terms of defining compile time variables for Dart, but also in terms of alternative way of environment configuration for application instead of flavors.

In my personal opinion, it would be helpful for developers to know about this feature when they're choosing the way how to setup they're configuration for multiple environments or just define compile-time variables.

I wrote small article about this feature and how it can be used instead of flavors. If it helps, feel free to use it)

sfshaza2 commented 4 years ago

Yes, this feature in 1.17 took me a bit by surprise! Have to figure out where to put it...

Roshan13046 commented 3 years ago

Yes, this feature in 1.17 took me a bit by surprise! Have to figure out where to put it...

can you please describe where to put the documentation about --dart-define key?

sfshaza2 commented 3 years ago

@Roshan13046, we now have a Flutter CLI page. It should go there.

Roshan13046 commented 3 years ago

Flutter 1.17 added support for custom compile-time variables in flutter tools with --dart-define

Quite interesting feature not just in terms of defining compile time variables for Dart, but also in terms of alternative way of environment configuration for application instead of flavors.

In my personal opinion, it would be helpful for developers to know about this feature when they're choosing the way how to setup they're configuration for multiple environments or just define compile-time variables.

I wrote small article about this feature and how it can be used instead of flavors. If it helps, feel free to use it)

The article link is not working. Can you please share a correct link for reference about the topic dart-define key?

TatsuUkraine commented 3 years ago

@Roshan13046 strange, it works for me, here is a friendly link from medium let me know if it works

sfshaza2 commented 3 years ago

I found another copy on binary-studio.

TatsuUkraine commented 3 years ago

@sfshaza2 it might be not up to date, I was making changes in the article on medium after 1.20 flutter release

TatsuUkraine commented 3 years ago

@sfshaza2 thanks for reminding me about it, btw) need to update it as well)

Roshan13046 commented 3 years ago

@sfshaza2 thanks for reminding me about it, btw) need to update it as well)

@Roshan13046 strange, it works for me, here is a friendly link from medium let me know if it works

Thanks! The link is working now. Should I include another row in the table of Page for --dart-define key or write a separate section for --dart-define key?

TatsuUkraine commented 1 year ago

hi, just curious, is there any update?) Flutter 3.7 recently introduced another way to pass compile-time variables, which probably also good to have in the docs

If it helps, I made another article about it, feel free to use it if needed