From 12357c0df3e811896435eafb53ad48a9e344b041 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Fri, 6 Sep 2024 13:17:00 +0000 Subject: [PATCH] [multiple] Avoid 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. Before adding the new warning to the analyzer, code in the engine needs to first be updated to eliminate these unreachable `default` clauses, so that the warning won't cause builds to break. For more information, see https://github.com/dart-lang/sdk/issues/54575. --- lib/web_ui/lib/src/engine/canvaskit/color_filter.dart | 2 -- lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart | 2 -- lib/web_ui/lib/src/engine/html/bitmap_canvas.dart | 2 -- lib/web_ui/lib/src/engine/html/shaders/shader.dart | 2 -- lib/web_ui/lib/src/engine/text/paragraph.dart | 2 -- lib/web_ui/lib/src/engine/text_editing/text_capitalization.dart | 1 - 6 files changed, 11 deletions(-) diff --git a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart index dea9b30130d8f..71c4123b4581a 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/color_filter.dart @@ -266,7 +266,5 @@ CkColorFilter? createCkColorFilter(EngineColorFilter colorFilter) { return const CkLinearToSrgbGammaColorFilter(); case ColorFilterType.srgbToLinearGamma: return const CkSrgbToLinearGammaColorFilter(); - default: - throw StateError('Unknown mode $colorFilter.type for ColorFilter.'); } } diff --git a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart index a2d7ab4bd8ae9..a99216b763748 100644 --- a/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart +++ b/lib/web_ui/lib/src/engine/canvaskit/embedded_views.dart @@ -844,8 +844,6 @@ class Mutator { return matrix == typedOther.matrix; case MutatorType.opacity: return alpha == typedOther.alpha; - default: - return false; } } diff --git a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart index 0dcd004bd557a..5d21eed1cf5dd 100644 --- a/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart +++ b/lib/web_ui/lib/src/engine/html/bitmap_canvas.dart @@ -1337,7 +1337,6 @@ String? stringForStrokeCap(ui.StrokeCap? strokeCap) { case ui.StrokeCap.round: return 'round'; case ui.StrokeCap.square: - default: return 'square'; } } @@ -1349,7 +1348,6 @@ String stringForStrokeJoin(ui.StrokeJoin strokeJoin) { case ui.StrokeJoin.bevel: return 'bevel'; case ui.StrokeJoin.miter: - default: return 'miter'; } } diff --git a/lib/web_ui/lib/src/engine/html/shaders/shader.dart b/lib/web_ui/lib/src/engine/html/shaders/shader.dart index 826d3cace3cb0..126c14770ded3 100644 --- a/lib/web_ui/lib/src/engine/html/shaders/shader.dart +++ b/lib/web_ui/lib/src/engine/html/shaders/shader.dart @@ -914,7 +914,5 @@ EngineHtmlColorFilter? createHtmlColorFilter(EngineColorFilter? colorFilter) { throw UnimplementedError('ColorFilter.linearToSrgbGamma not implemented for HTML renderer'); case ColorFilterType.srgbToLinearGamma: throw UnimplementedError('ColorFilter.srgbToLinearGamma not implemented for HTML renderer.'); - default: - throw StateError('Unknown mode $colorFilter.type for ColorFilter.'); } } diff --git a/lib/web_ui/lib/src/engine/text/paragraph.dart b/lib/web_ui/lib/src/engine/text/paragraph.dart index a042c67b72788..dbb88918ddfb7 100644 --- a/lib/web_ui/lib/src/engine/text/paragraph.dart +++ b/lib/web_ui/lib/src/engine/text/paragraph.dart @@ -1118,8 +1118,6 @@ String? _decorationStyleToCssString(ui.TextDecorationStyle decorationStyle) { return 'solid'; case ui.TextDecorationStyle.wavy: return 'wavy'; - default: - return null; } } diff --git a/lib/web_ui/lib/src/engine/text_editing/text_capitalization.dart b/lib/web_ui/lib/src/engine/text_editing/text_capitalization.dart index 8a81829c3cc41..b230fcfaa4973 100644 --- a/lib/web_ui/lib/src/engine/text_editing/text_capitalization.dart +++ b/lib/web_ui/lib/src/engine/text_editing/text_capitalization.dart @@ -75,7 +75,6 @@ class TextCapitalizationConfig { case TextCapitalization.sentences: autocapitalize = 'sentences'; case TextCapitalization.none: - default: autocapitalize = 'off'; } if (domInstanceOfString(domElement, 'HTMLInputElement')) {