close method
Permanently stops the WebSocket connection and frees all resources. After calling this method the WebSocket client is no longer usable.
Use disconnect to temporarily close the connection. And reconnect with connect method later.
Implementation
@override
@visibleForTesting
FutureOr<void> close(
[int? code = 1000, String? reason = 'NORMAL_CLOSURE']) async {
_isClosed = true;
await disconnect(code, reason);
await Future<void>.delayed(Duration.zero);
await _stateController.close();
await _controller.close();
}