Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[camerax] Ignore new unreachable_switch_default warning.
The Dart analyzer will soon be changed so that if the `default` clause
of a `switch` statement is determined to be unreachable by the
exhaustiveness checker, a new warning of type
`unreachable_switch_default` will be issued. This parallels the
behavior of the existing `unreachable_switch_case` warning, which is
issued whenever a `case` clause of a `switch` statement is determined
to be unreachable.

In the vast majority of cases, the most reasonable way to address the
warning is to remove the unreachable `default` clause. However, in a
few rare cases, it makes sense to keep the `default` clause, because
it's intentionally future-proofing the code in case new possible
values are added to the enum being switched on.

Three of these rare cases crop up in the camerax package. This change
adds `ignore` comments to avoid a spurious warning.
  • Loading branch information
stereotype441 committed Sep 6, 2024
commit 7bd9a884f3d7d68680f89635d32a3f5f539ffbb5
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _CaptureRequestOptionsHostApiImpl extends CaptureRequestOptionsHostApi {
// This ignore statement is safe beause this error will be useful when
// a new CaptureRequestKeySupportedType is being added, but the logic in
// this method has not yet been updated.
// ignore: no_default_cases
// ignore: no_default_cases, unreachable_switch_default
default:
throw ArgumentError(CaptureRequestOptions
.getUnsupportedCaptureRequestKeyTypeErrorMessage(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class LiveDataFlutterApiImpl implements LiveDataFlutterApi {
// This ignore statement is safe beause this error will be useful when
// a new LiveDataSupportedType is being added, but the logic in this method
// has not yet been updated.
// ignore: no_default_cases
// ignore: no_default_cases, unreachable_switch_default
default:
throw ArgumentError(LiveData.unsupportedLiveDataTypeErrorMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void main() {
// This ignore statement is safe beause this will test when
// a new CaptureRequestKeySupportedType is being added, but the logic in
// in the CaptureRequestOptions class has not yet been updated.
// ignore: no_default_cases
// ignore: no_default_cases, unreachable_switch_default
default:
fail(
'Option $option contains unrecognized CaptureRequestKeySupportedType key ${option.$1}');
Expand Down