toString method
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 Uint8List chars = Uint8List(_length);
int charIndex = 0;
final int fullBytes = _length >> 3;
for (int i = 0; i < fullBytes; i++) {
final int byte = _buffer[i];
for (int j = 7; j >= 0; j--) {
chars[charIndex++] = ((byte >> j) & 1) + 48;
}
}
final int remainingBits = _length & 7;
if (remainingBits > 0) {
final int byte = _buffer[fullBytes];
for (int i = 0; i < remainingBits; i++) {
chars[charIndex++] = ((byte >> (7 - i)) & 1) + 48;
}
}
return String.fromCharCodes(chars);
}