toBinArray method

Uint8List toBinArray({
  1. int? start,
  2. int? end,
  3. int? pad,
  4. int? size,
  5. bool isApplication = false,
})

Place the hex file into a binary array

Implementation

Uint8List toBinArray({int? start, int? end, int? pad, int? size, bool isApplication = false}){
  //Return binary array.
  pad ??= padding;
  List<int> bin = [];
  if(buffer == {}){
    throw Exception("No Data in buffer");
  }
  if(size != null && size <= 0){
    throw Exception("tobinarray: wrong value for size");
  }
  List<int> temp = _getStartEnd(start, end, size);
  start = temp[0];
  end = isApplication?temp[1]:min(temp[1],largest);
  for(int i = start; i < end+1; i++){
    if(buffer[i+pad] != null){
      bin.add(buffer[i+pad]!);
    }
  }
  return Uint8List.fromList(bin);
}