decodeVarintAsInteger method

LayoutDecodeResult<int> decodeVarintAsInteger(
  1. int offset
)

Decodes a varint at offset as a Dart int.

Implementation

LayoutDecodeResult<int> decodeVarintAsInteger(int offset) {
  final decode = LayoutSerializationUtils.decodeVarint(
    _bytes,
    offset: offset,
  );
  if (!decode.value.isSafeInt()) {
    throw const BuError(
      DefaultErrorType.invalidLength,
      "varint number is too large for int.",
    );
  }
  return LayoutDecodeResult(
    consumed: decode.consumed,
    value: decode.value.toInt(),
  );
}