parseBinaryDataResponse function

List parseBinaryDataResponse(
  1. ReadBuffer buffer,
  2. List<Field> fields
)

Implementation

List<dynamic> parseBinaryDataResponse(ReadBuffer buffer, List<Field> fields) {
  buffer.skip(1);
  var nulls = buffer.readList(((fields.length + 7 + 2) / 8).floor().toInt());
  var nullMap = List<bool?>.filled(fields.length, null, growable: false);
  var shift = 2;
  var byte = 0;

  for (var i = 0; i < fields.length; i++) {
    var mask = 1 << shift;
    nullMap[i] = (nulls[byte] & mask) != 0;
    shift++;
    if (shift > 7) {
      shift = 0;
      byte++;
    }
  }

  final values = List<dynamic>.filled(fields.length, null);
  for (var i = 0; i < fields.length; i++) {
    if (nullMap[i]!) {
      values[i] = null;
      continue;
    }
    var field = fields[i];
    values[i] = _readField(field, buffer);
  }

  return values;
}