How do you pass variables to main in Dart?
Sounds like you are building a browser app?
(BTW, you can use new Options().arguments
for command-line apps. Works great, but obviously there is no command line in browser apps :)
(Second, main()
doesn't take arguments, so we have to find another way.)
OK, for a browser-app, what I might try doing is embedding some JSON into the page inside a <script>
tag. Then, using query, find that element, parse the contents, and you're good to go.
In your HTML:
<script id="config">
{"environment":"test"}
</script>
And in your Dart file:
import 'dart:html';
import 'dart:json' as json;
void main() {
var config = json.parse(query("#config").innerHtml);
print(config['environment']);
}
Hope that helps!