You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add documentation for using 'dart-define' with Dart apps #3578
I had trouble using dart-define after following https://dartcode.org/docs/using-dart-define-in-flutter/, not thinking about the fact that my app was a Dart app, not a Flutter app. I got it working in the end with a launch config like this:
The differences that matter (as I understand) are -D instead of dart-define and using "toolArgs" rather than "args". I think I understand why in both cases but I found that info with a fair bit of digging. I think it would be helpful to add some documentation for Dart apps like there is for Flutter.
Thanks - I'll add a Dart page about this, and link the two together. I think probably toolArgs is the right thing for both now, but I'll verify that before updating. Thanks!
Awesome thanks @DanTup! May I ask did you use --define because it's clearer or is there some functional difference? By the way is the use of --define officially documented somewhere that you know of? I searched the SDK repo and I see in the code that -D and --define appear to be interchangeable (I think?), but I can't seem to track down any actual documentation
Yep, they're both the same. I got the long form from dart run --help -v (although it's not super detailed):
Advanced options:
-D, --define=<key=value> Define an environment declaration.
I tend to prefer the more descriptive names for things like documentation (or where they're being included by scripts) because it's easier for readers to understand and/of search for them if you don't know what they might be called from the abbreviation.
Whoops, just checked and regular old dart run --help gives the "Define an environment declaration." information... I could have sworn I looked in the help 🤦 well I learned about -v anyway so that's awesome! 🙂
Activity
DanTup commentedon Sep 28, 2021
Thanks - I'll add a Dart page about this, and link the two together. I think probably
toolArgsis the right thing for both now, but I'll verify that before updating. Thanks!DanTup commentedon Sep 29, 2021
I've updated https://dartcode.org/docs/using-dart-define-in-flutter/ to use
toolArgsfor consistency, and also added a link at the bottom about using--definein Dart (linking here with an example of that). Thanks!nickmeinhold commentedon Sep 29, 2021
Awesome thanks @DanTup! May I ask did you use --define because it's clearer or is there some functional difference? By the way is the use of --define officially documented somewhere that you know of? I searched the SDK repo and I see in the code that -D and --define appear to be interchangeable (I think?), but I can't seem to track down any actual documentation
DanTup commentedon Sep 29, 2021
Yep, they're both the same. I got the long form from
dart run --help -v(although it's not super detailed):I tend to prefer the more descriptive names for things like documentation (or where they're being included by scripts) because it's easier for readers to understand and/of search for them if you don't know what they might be called from the abbreviation.
nickmeinhold commentedon Sep 29, 2021
Oh there's a verbose help! I'm very glad I asked, that's great to know about, thanks heaps!
nickmeinhold commentedon Sep 29, 2021
Whoops, just checked and regular old
dart run --helpgives the "Define an environment declaration." information... I could have sworn I looked in the help 🤦 well I learned about -v anyway so that's awesome! 🙂