question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, 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!

0reactions
nickmeinholdcommented, Sep 29, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to setup dart-define for keys and secrets on Android and ...
Head over to android/app/build.gradle and we'll be using the following code to parse every available variable from --dart-define and make them available as ......
Read more >
Effective Dart: Documentation
Effective Dart: Documentation · DO use /// doc comments to document members and types. · PREFER writing doc comments for public APIs. ·...
Read more >
Using --dart-define in Flutter - Dart Code
You can pass additional --dart-define values to Flutter by specifying them in the toolArgs field of your launch configuration ( launch.json ):.
Read more >
How to use --dart-define in a Flutter app embdedded in Android
Was looking for a way to add "dart-define" to the gradle command so that the embedded Flutter app will have it available at...
Read more >
How to Store API Keys in Flutter: --dart ... - Code With Andrea
Compiling and running the app with --dart-define. The main advantage of using --dart-define is that we're no longer hardcoding sensitive keys in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found