decode static method

CID decode(
  1. String cidStr
)

Decodes a CID from its string representation.

Implementation

static CID decode(String cidStr) {
  if (cidStr.isEmpty) {
    throw ArgumentError('Empty CID string');
  }

  if (cidStr.startsWith('Qm')) {
    // CIDv0 is base58btc without the multibase prefix character.
    final decoded = MultibaseUtils.decode('z$cidStr');
    return fromBytes(decoded);
  }

  final decoded = MultibaseUtils.decode(cidStr);
  return fromBytes(decoded);
}