toString method

  1. @override
String toString()
override

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() {
  final suites = cipherSuites
      .map((s) => cipherSuitesMap[s] ?? 'Unknown (0x${s.toRadixString(16)})')
      .join(',\n    ');

  return '''
✅ Parsed ClientHello (Type 0x01):
- Legacy Version: 0x${legacyVersion.toRadixString(16)}
- Random: ${HEX.encode(random.sublist(0, 8))}...
- Session ID: ${HEX.encode(sessionId)}
- Cipher Suites:
  $suites
- Supported Versions: ${supportedVersions ?? []}
- Supported Groups: ${supportedGroups ?? []}
- Signature Algorithms: ${signatureAlgorithms ?? []}
- ALPN: ${alpn ?? []}
- Key Share: ${keyShares ?? []}
- Extensions Count: ${extensions.length}
''';
}