read method

List read()

Implementation

List<dynamic> read() {
  Uint8List buffer = val is BigInt ? _bigIntToBytes(val) : val;

  if (buffer.length > bytelen) {
    throw Exception('Out of Bounds!');
  }

  if (buffer.isEmpty) {
    buffer = Uint8List.fromList([0]);
  }

  BigInt bigI = BigInt.parse(
      buffer.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join(),
      radix: 16);

  // Check if the number can be represented as an int, otherwise use BigInt
  int num;
  try {
    num = bigI.toInt();
  } catch (_) {
    num = 0; // Or handle differently if necessary
  }

  return [num != bigI ? bigI : num, Uint8List(0)];
}