setBool method
Writes a boolean
value to 1-byte
.
The offset
must satisy the relations 0
≤ offset
≤ offset+1
≤ this.length
.
Returns the position of the last element written to the buffer ([offset]+1
).
final Buffer buffer = Buffer(1);
buffer.setBool(true, 0);
print(buffer); // [1]
buffer.setBool(false, 0);
print(buffer); // [0]
Implementation
int setBool(final bool value, final int offset) {
asByteData().setUint8(offset, value ? 1 : 0);
return offset + ByteLength.u8;
}