unused_label
The label '{0}' isn't used.
Description
#The analyzer produces this diagnostic when a label that isn't used is found.
Example
#The following code produces this diagnostic because the label loop
isn't
referenced anywhere in the method:
dart
void f(int limit) {
loop: for (int i = 0; i < limit; i++) {
print(i);
}
}
Common fixes
#If the label isn't needed, then remove it:
dart
void f(int limit) {
for (int i = 0; i < limit; i++) {
print(i);
}
}
If the label is needed, then use it:
dart
void f(int limit) {
loop: for (int i = 0; i < limit; i++) {
print(i);
if (i != 0) {
break loop;
}
}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。