toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
  String dateTimeRepresentation(DateTime? time, {bool ago = false}) =>
      time != null
          ? '${DateTime.now().difference(time).abs().inSeconds} seconds '
              '${ago ? 'ago' : 'from now'}'
          : 'never';
  return 'readyState: ${readyState.name}\n'
      'reconnectTimeout: ${reconnectTimeout.inSeconds} seconds\n'
      'transferredSize: $transferredSize\n'
      'receivedSize: $receivedSize\n'
      'transferredCount: $transferredCount\n'
      'receivedCount: $receivedCount\n'
      'reconnects: ${reconnects.successful} / ${reconnects.total}\n'
      'lastSuccessfulConnectionTime: '
      '${dateTimeRepresentation(lastSuccessfulConnectionTime, ago: true)}\n'
      'disconnects: $disconnects\n'
      'lastDisconnectTime: '
      '${dateTimeRepresentation(lastDisconnectTime, ago: true)}\n'
      'expectedReconnectTime: '
      '${dateTimeRepresentation(expectedReconnectTime)}\n'
      'lastDisconnect: '
      '${lastDisconnect.code ?? 'unknown'} '
      '(${lastDisconnect.reason ?? 'unknown'})\n'
      'lastUrl: ${lastUrl ?? 'not connected yet'}';
}