getValueAsBytes method

Uint8List getValueAsBytes(
  1. int row,
  2. int column, {
  3. int? length,
})

Implementation

Uint8List getValueAsBytes(int row, int column, {int? length}) {
  if (row < 0 || row >= rows || column < 0 || column >= columns)
    throw LibPqException("Row or column index out of range!");
  final valuePoiter = psql.pq.PQgetvalue(res, row, column);

  int _length(Pointer<Uint8> codeUnits) {
    var length = 0;
    while (codeUnits[length] != 0) {
      length++;
    }
    return length;
  }

  final codeUnits = valuePoiter.cast<Uint8>();
  if (length != null) {
    RangeError.checkNotNegative(length, 'length');
  } else {
    length = _length(codeUnits);
  }
  return codeUnits.asTypedList(length);
}