Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Flutter remove debug-mode code when compiling for release?

I'm wondering whether it is safe to place passwords directly in the Dart code like below. Does Flutter remove the code when compiling it for release? Of course I want to make sure that the code cannot be decompiled such that the username and password can be extracted.

bool get isInDebugMode {
  bool inDebugMode = false;
  assert(inDebugMode = true);
  return inDebugMode;
}

if(inDebugMode){
  emailController.text = '[email protected]';
  passwordController.text = 'secret';
}
like image 602
Menno Avatar asked Oct 17 '25 06:10

Menno


1 Answers

The code you provided won't be tree-shaked. As isInDebugMode isn't a constant.

Instead you can use an assert this way:

assert(() {
  emailController.text = '[email protected]';
  passwordController.text = 'secret';
  return true;
}());
like image 149
Rémi Rousselet Avatar answered Oct 19 '25 20:10

Rémi Rousselet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!