How can I check if a Flutter application is running in debug?

In later versions, you can use kDebugMode: if (kDebugMode) doSomething(); While asserts can technically be used to manually create an “is debug mode” variable, you should avoid that. Instead, use the constant kReleaseMode from package:flutter/foundation.dart The difference is all about tree shaking. Tree shaking (aka the compiler removing unused code) depends on variables being constants. … Read more