unreachable_ switch_ case
Details about the 'unreachable_switch_case' diagnostic produced by the Dart analyzer.
This case is covered by the previous cases.
Description
#
The analyzer produces this diagnostic when a
case clause in a switch statement
doesn't match anything because all of the matchable values are
matched by an earlier case clause.
Example
#
The following code produces this diagnostic because the value
1 was matched in the preceding case:
void f(int x) {
switch (x) {
case 1:
print('one');
case 1:
print('two');
}
}
Common fixes
#Change one or both of the conflicting cases to match different values:
void f(int x) {
switch (x) {
case 1:
print('one');
case 2:
print('two');
}
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.