readBool method

bool readBool([
  1. bool strict = false
])

read bool, represented by a single byte if the byte is not 1, it would be false if in strict mode, any value other than 1 or 0 will throw

Implementation

bool readBool([bool strict = false]) {
  int b = readByte();
  if (strict && b != 0 && b != 1) {
    throw FormatException("[Strict Mode] Invalid bool encoding");
  }
  return b == 1;
}