我想知道像下面这样将密码直接放在 Dart 代码中是否安全。 Flutter 在编译发布的时候会去掉代码吗?当然我要确保代码不能被反编译,这样才能提取用户名和密码。
bool get isInDebugMode {
bool inDebugMode = false;
assert(inDebugMode = true);
return inDebugMode;
}
if(inDebugMode){
emailController.text = 'random@email.com';
passwordController.text = 'secret';
}
最佳答案
您提供的代码不会进行 tree-shaking。因为 isInDebugMode
不是常量。
相反,您可以这样使用 assert
:
assert(() {
emailController.text = 'random@email.com';
passwordController.text = 'secret';
return true;
}());
关于debugging - Flutter 在编译发布时是否删除 Debug模式代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53225385/