Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect during runtime whether the application is in release mode or not

Tags:

build

dart

I got a bunch of tests and debug stuff in my Dart application and I would like to make sure these kind of things are disabled when I build a release version with pub.

Is there any constant or some other way to check if the current running version of the application is a release build or not?

Example:

if (!IS_BUILD) {
   performAutomatedDummyLogin()
} else {
   login();
}
like image 204
Basic Coder Avatar asked Apr 12 '15 18:04

Basic Coder


Video Answer


1 Answers

Code in assert(...); is only executed in checked (development) mode. When you run in release mode or build in release mode this code isn't executed.

bool isRelease = true;
assert(() {
  isRelease = false;
  return true;
});

if(isRelease) {
 ...
} 

see also

  • Dart: How to use different settings in debug and production mode?
  • How to achieve precompiler directive like functionality
  • Is there a compiler preprocessor in Dart?
like image 108
Günter Zöchbauer Avatar answered Sep 29 '22 10:09

Günter Zöchbauer