From 67bf9a304a2102b632db60d251a3409e9fd0472d Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 23 Nov 2023 07:08:30 -0800 Subject: [PATCH] Drop some use of ! (#296) Use an if-case and destructure to new local variables to avoid some throw-if-null operator usage. --- lib/html.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/html.dart b/lib/html.dart index 6b3ea6e..82edd2d 100644 --- a/lib/html.dart +++ b/lib/html.dart @@ -145,10 +145,11 @@ class HtmlWebSocketChannel extends StreamChannelMixin // On Chrome and possibly other browsers, `null` can't be passed as the // default here. The actual arity of the function call must be correct or // it will fail. - if (_localCloseCode != null && _localCloseReason != null) { - innerWebSocket.close(_localCloseCode!, _localCloseReason!); - } else if (_localCloseCode != null) { - innerWebSocket.close(_localCloseCode!); + if ((_localCloseCode, _localCloseReason) + case (final closeCode?, final closeReason?)) { + innerWebSocket.close(closeCode, closeReason); + } else if (_localCloseCode case final closeCode?) { + innerWebSocket.close(closeCode); } else { innerWebSocket.close(); }