Dart: How to use different settings in debug and production mode?
Asked Answered
A

1

5

Are there any ideas how I can setup my Dart app to use different settings in debug mode (running in Dartium) and production mode?

For example, I'm using PouchDb in my app, that replicates the database to a particular CouchDb instance, given by an url: db.replicateTo(url); In debug mode, I would like to use another CouchDb instance (another url) than in production mode.

So, are there any ideas or approaches, to use different setups in both modes?

Arpeggio answered 19/3, 2014 at 22:32 Comment(0)
M
8

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

Maidamaidan answered 20/3, 2014 at 5:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.