this works since a short while:
transformers: # or dev_transformers
- $dart2js:
environment: { PROD: "true" }
access it from the code like
String.fromEnvironment()
main() {
print('PROD: ${const String.fromEnvironment('PROD')}');
// works in the browser
// prints 'PROD: null' in Dartium
// prints 'PROD: true' in Chrome
}
see also
- Configuring the Built-in dart2js Transformer
- How to achieve precompiler directive like functionality
- https://github.com/dart-lang/pub/issues/798
- http://blog.sethladd.com/2013/12/compile-time-dead-code-elimination-with.html
- https://api.dartlang.org/stable/1.22.0/dart-core/bool/bool.fromEnvironment.html
- dart check if is building