flutter - Flutter:如何防止在调试控制台中打印异常?
问题描述
我正在使用 try catch 进行错误处理并在出现错误时显示小部件。这有效,但调试控制台中仍会打印异常,这种情况下的异常是IOException
,如何防止此异常在控制台中打印?
try {
PDFDocument pdfDocument = await PDFDocument.fromURL(pdfUrl);
Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) =>
DisplayPdf(pdfDocument),
),
);
} catch (error) {
showDialog(...);
}
fromURL
我正在使用的pdf包中的函数代码:
static Future<PDFDocument> fromURL(String url) async {
// Download into cache
File f = await DefaultCacheManager().getSingleFile(url);
PDFDocument document = PDFDocument();
document._filePath = f.path;
try {
var pageCount =
await _channel.invokeMethod('getNumberOfPages', {'filePath': f.path});
document.count = document.count = int.parse(pageCount);
} catch (e) {
throw Exception('Error reading PDF!');
}
return document;
}
解决方案
推荐阅读
- angular - 如何将带有图像的 HTML 转换为 PDF
- python - python中的Numba jit警告解释
- liquibase - Liquibase 多个 includeAll 语句
- pandas - 如何用现有列值替换 DataFrame 列的 NaN 值?
- cmd - 如何将文件中的一些文本保存到cmd中的变量?
- javascript - 在 FlaskSocketIO 聊天中设置动态聊天室
- apache-spark - 从 cosmos 到 ADLS 的数据归档
- javascript - 如何根据人员数组长度的可分值准备数组?
- java - java - 如何在Java中使用HTTPDELETE作为RequestBody发送列表参数
- visual-studio-code - 如何选择 TM_DIRECTORY 变量的一部分?