asn1ToString method Null safety

String asn1ToString(
  1. dynamic obj
)

Implementation

String asn1ToString(dynamic obj) {
  if (obj is ASN1Object) {
    obj = asn1ToDart(obj);
  }

  if (obj is String) {
    return obj;
  }
  if (obj is Uint8List) {
    return toHex(obj);
  }
  if (obj is ASN1ObjectIdentifier) {
    return obj.name;
  }
  if (obj is ASN1Integer) {
    return obj.integer.toString();
  }
  if (obj is ASN1Sequence) {
    return obj.elements?.map<String>((e) => asn1ToString(e)).join(', ') ??
        'empty sequence';
  }

  return obj.toString();
}