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

Add documentation for using 'dart-define' with Dart apps #3578

Closed
nickmeinhold opened this issue Sep 28, 2021 · 6 comments
Closed

Add documentation for using 'dart-define' with Dart apps #3578

nickmeinhold opened this issue Sep 28, 2021 · 6 comments
Labels
in docs / website Relates to documentation, including the Dart Code website
Milestone

Comments

@nickmeinhold
Copy link

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:

{
  "name": "Dart",
  "request": "launch",
  "type": "dart",
  "program": "bin/dart_program.dart",
  "toolArgs": ["-Dkey=blah"]
}

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!

@DanTup DanTup added this to the v3.27.0 milestone Sep 28, 2021
@DanTup DanTup added the in docs / website Relates to documentation, including the Dart Code website label Sep 28, 2021
@DanTup
Copy link
Member

DanTup commented Sep 28, 2021

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!

@DanTup
Copy link
Member

DanTup commented Sep 29, 2021

I've updated https://dartcode.org/docs/using-dart-define-in-flutter/ to use toolArgs for consistency, and also added a link at the bottom about using --define in Dart (linking here with an example of that). Thanks!

@DanTup DanTup closed this as completed Sep 29, 2021
@nickmeinhold
Copy link
Author

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
Copy link
Member

DanTup commented 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):

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.

@nickmeinhold
Copy link
Author

Oh there's a verbose help! I'm very glad I asked, that's great to know about, thanks heaps!

@nickmeinhold
Copy link
Author

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! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in docs / website Relates to documentation, including the Dart Code website
Projects
None yet
Development

No branches or pull requests

2 participants