Assessors are executed only in verification mode and will not be enabled in the pub builddefault production mode:
assert(() {
Log.print('something ${StackTrace.current}');
return true;
})
Example DartPad does not print it because it builds in run mode.
You can also pass the "environment" (without mixing with OS environment variables) before pub buildand read it in code
transformers:
- $dart2js:
environment: { PROD: "true" }
const prod = String.fromEnvironment('PROD')
print('PROD: $prod');
// prints 'PROD: null' in Dartium
// prints 'PROD: true' in Chrome
See also fooobar.com/questions/1532569 / ...