toUnsigned method

int toUnsigned()

Returns the unsigned representation of this byte (0-255).

For single bytes only.

Example:

final b1 = Byte(100);
final b2 = Byte(-56);

print(b1.toUnsigned());  // 100
print(b2.toUnsigned());  // 200

Throws NoGuaranteeException if this represents multiple bytes.

Implementation

int toUnsigned() {
  if (!isSingleByte) {
    throw NoGuaranteeException('Cannot convert byte array to single unsigned value');
  }
  return _signedToUnsigned(_bytes[0]);
}