Skip to content

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

Closed

Description

@nickmeinhold

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!

Activity

  1. added this to the v3.27.0 milestone on Sep 28, 2021
  2. added
    in docs / websiteRelates to documentation, including the Dart Code website
    on Sep 28, 2021
  3. DanTup commented on Sep 28, 2021

    @DanTup
    Member

    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!

  4. DanTup commented on Sep 29, 2021

    @DanTup
    Member

    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!

  5. nickmeinhold commented on Sep 29, 2021

    @nickmeinhold
    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

  6. DanTup commented on Sep 29, 2021

    @DanTup
    Member

    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.

  7. nickmeinhold commented on Sep 29, 2021

    @nickmeinhold
    Author

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

  8. nickmeinhold commented on Sep 29, 2021

    @nickmeinhold
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in docs / websiteRelates to documentation, including the Dart Code website

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions