onClose method

void onClose(
  1. dynamic callback(
    1. dynamic
    )
)

Adds a callback handler to this WebSocket close event.

If this WebSocket closes a done event is triggered, the onClose handler is called. If onClose is null, nothing happens.

If you are not listening to this close event you are not going to be able to know if the connection was closed.

Implementation

void onClose(Function(dynamic) callback) {
  _closeCallback = callback;
  _startCloseServices().then((_) {
    _onClose();
  });
}