setBool method

int setBool(
  1. bool value,
  2. int offset
)

Writes a boolean value to 1-byte.

The offset must satisy the relations 0offsetoffset+1this.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;
}