getAt method

bool getAt(
  1. int position
)

Implementation

bool getAt(int position) {
  if (position > _length) {
    throw Exception('requested position is out of range');
  }
  var posInData = position ~/ 8;
  var posInByte = position % 8;

  var byte = _data[posInData];
  var asString = byte.toRadixString(2).padLeft(8, '0').split('');

  var bit = asString[posInByte];
  if (bit == '0') {
    return false;
  } else {
    return true;
  }
}