Aja*_*mar 5 logging android debug-print flutter
我已经在android设备中安装了发行版本的apk,但是如果我将该设备连接到Android studio,则可以看到所有Logs / debugPrint语句。
有什么办法可以禁用所有日志?
我将接受的答案与这里的想法结合起来,并使用它 main.dart 使所有 debugPrint 无处不在。
const bool isProduction = bool.fromEnvironment('dart.vm.product');
void main() {
if (isProduction) {
debugPrint = (String message, {int wrapWidth}) {};
}
runApp(
MyApp()
);
}
Run Code Online (Sandbox Code Playgroud)
您可以为全局debugPrint变量分配一个虚拟函数:
import 'package:flutter/material.dart';
main() {
debugPrint = (String message, {int wrapWidth}) {};
}
Run Code Online (Sandbox Code Playgroud)