From 33b26ff5a7bd93955a9f9a6b5d7dd703b047e7e4 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 20 Dec 2021 14:53:19 -0800 Subject: [PATCH] Add missing return to nullably-typed functions (flutter/engine#30382) --- .../lib/web_ui/dev/steps/run_tests_step.dart | 2 ++ .../lib/src/engine/safe_browser_api.dart | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/lib/web_ui/dev/steps/run_tests_step.dart b/engine/src/flutter/lib/web_ui/dev/steps/run_tests_step.dart index 0ea00171a5..d5601c2db7 100644 --- a/engine/src/flutter/lib/web_ui/dev/steps/run_tests_step.dart +++ b/engine/src/flutter/lib/web_ui/dev/steps/run_tests_step.dart @@ -195,6 +195,8 @@ class RunTestsStep implements PipelineStep { if (requireSkiaGold) { throw ToolExit('Skia Gold is required but is unavailable.'); } + + return null; } /// Checks whether the Skia Client is usable in this environment. diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/safe_browser_api.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/safe_browser_api.dart index 756f2d3132..309c4c31d1 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/safe_browser_api.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/safe_browser_api.dart @@ -200,19 +200,20 @@ html.CanvasElement? tryCreateCanvasElement(int width, int height) { 'createElement', ['CANVAS'], ); - if (canvas != null) { - try { - canvas.width = width; - canvas.height = height; - } catch (e) { - // It seems the tribal knowledge of why we anticipate an exception while - // setting width/height on a non-null canvas and why it's OK to return - // null in this case has been lost. Kudos to the one who can recover it - // and leave a proper comment here! - return null; - } - return canvas; + if (canvas == null) { + return null; } + try { + canvas.width = width; + canvas.height = height; + } catch (e) { + // It seems the tribal knowledge of why we anticipate an exception while + // setting width/height on a non-null canvas and why it's OK to return null + // in this case has been lost. Kudos to the one who can recover it and leave + // a proper comment here! + return null; + } + return canvas; } @JS('window.ImageDecoder')