readSize method Null safety

int readSize(
  1. ReadBuffer buffer
)

Reads a non-negative int from buffer as written by writeSize.

This method is intended for use by subclasses overriding readValueOfType.

Implementation

int readSize(ReadBuffer buffer) {
  final int value = buffer.getUint8();
  switch (value) {
    case 254:
      return buffer.getUint16();
    case 255:
      return buffer.getUint32();
    default:
      return value;
  }
}