Skip to content

Commit

Permalink
Drop some use of ! (#296)
Browse files Browse the repository at this point in the history
Use an if-case and destructure to new local variables to avoid some
throw-if-null operator usage.
  • Loading branch information
natebosch authored Nov 23, 2023
1 parent d4a8d70 commit 67bf9a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 67bf9a3

Please sign in to comment.