Skip to content

Commit 03623b6

Browse files
[camerax] Ignore new unreachable_switch_default warning. (flutter#7592)
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.
1 parent d07c025 commit 03623b6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/camera/camera_android_camerax/lib/src/capture_request_options.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class _CaptureRequestOptionsHostApiImpl extends CaptureRequestOptionsHostApi {
115115
// This ignore statement is safe beause this error will be useful when
116116
// a new CaptureRequestKeySupportedType is being added, but the logic in
117117
// this method has not yet been updated.
118-
// ignore: no_default_cases
118+
// ignore: no_default_cases, unreachable_switch_default
119119
default:
120120
throw ArgumentError(CaptureRequestOptions
121121
.getUnsupportedCaptureRequestKeyTypeErrorMessage(key));

packages/camera/camera_android_camerax/lib/src/live_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class LiveDataFlutterApiImpl implements LiveDataFlutterApi {
185185
// This ignore statement is safe beause this error will be useful when
186186
// a new LiveDataSupportedType is being added, but the logic in this method
187187
// has not yet been updated.
188-
// ignore: no_default_cases
188+
// ignore: no_default_cases, unreachable_switch_default
189189
default:
190190
throw ArgumentError(LiveData.unsupportedLiveDataTypeErrorMessage);
191191
}

packages/camera/camera_android_camerax/test/capture_request_options_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void main() {
132132
// This ignore statement is safe beause this will test when
133133
// a new CaptureRequestKeySupportedType is being added, but the logic in
134134
// in the CaptureRequestOptions class has not yet been updated.
135-
// ignore: no_default_cases
135+
// ignore: no_default_cases, unreachable_switch_default
136136
default:
137137
fail(
138138
'Option $option contains unrecognized CaptureRequestKeySupportedType key ${option.$1}');

0 commit comments

Comments
 (0)