From 9384b41876892e76c4a6acbef72a5ae8a16a3480 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 22 Nov 2023 21:54:11 +0000 Subject: [PATCH] Drop some use of ! 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(); }