debugging - Flutter 在编译发布时会删除调试模式代码吗?
问题描述
我想知道将密码直接放在下面的 Dart 代码中是否安全。Flutter 在编译发布时会删除代码吗?当然,我要确保代码不能被反编译,以便提取用户名和密码。
bool get isInDebugMode {
bool inDebugMode = false;
assert(inDebugMode = true);
return inDebugMode;
}
if(inDebugMode){
emailController.text = 'random@email.com';
passwordController.text = 'secret';
}
解决方案
您提供的代码不会被摇树。因为isInDebugMode
不是一个常数。
相反,您可以使用assert
这种方式:
assert(() {
emailController.text = 'random@email.com';
passwordController.text = 'secret';
return true;
}());