kDebugMode top-level constant

bool const kDebugMode

A constant that is true if the application was compiled in debug mode.

More specifically, this is a constant that is true if the application was not compiled with '-Ddart.vm.product=true' and '-Ddart.vm.profile=true'.

Since this is a const value, it can be used to indicate to the compiler that a particular block of code will not be executed in debug mode, and hence can be removed.

An alternative strategy is to use asserts, as in:

assert(() {
  // ...debug-only code here...
  return true;
}());

See also:

Implementation

const bool kDebugMode = !kReleaseMode;