isAtPadding method

bool isAtPadding({
  1. int? paddingPosition,
})

If the current buffer is at the padding position, it consumes the padding bits and then returns true. If not, it simply returns false without changing the internal buffer's status or position.

If the paddingPosition is not explicitly passed, its value will be set to the last byte position of the bytesBuffer.

Implementation

bool isAtPadding({int? paddingPosition}) {
  paddingPosition ??= _bytesBuffer.length - 1;
  final pos = _bytesBuffer.position;

  if (pos >= paddingPosition) {
    if ((pos == paddingPosition && _bitsBufferLength == 0) ||
        (pos > paddingPosition && _bitsBufferLength > 0)) {
      var padding = readPadding();
      if (padding > 0) {
        return true;
      }
    }
  }

  return false;
}