toRadixString method

String toRadixString(
  1. int radix
)

Returns a string representation in the specified radix.

For single bytes only.

Example:

final b = Byte(42);
print(b.toRadixString(16));  // '2a'
print(b.toRadixString(2));   // '101010'
print(b.toRadixString(8));   // '52'

Throws NoGuaranteeException if this represents multiple bytes.

Implementation

String toRadixString(int radix) {
  if (!isSingleByte) {
    throw NoGuaranteeException('Cannot convert byte array to single radix string');
  }
  return toUnsigned().toRadixString(radix);
}