unused_catch_stack
The stack trace variable '{0}' isn't used and can be removed.
Description
#The analyzer produces this diagnostic when the stack trace parameter in a
catch
clause isn't referenced within the body of the catch
block.
Example
#The following code produces this diagnostic because stackTrace
isn't
referenced:
dart
void f() {
try {
// ...
} catch (exception, stackTrace) {
// ...
}
}
Common fixes
#If you need to reference the stack trace parameter, then add a reference to it. Otherwise, remove it:
dart
void f() {
try {
// ...
} catch (exception) {
// ...
}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。