bitstreamToBytes method

Uint8List bitstreamToBytes(
  1. String stream
)

Implementation

Uint8List bitstreamToBytes(String stream) {
  var result = <int>[];
  var str = stream;

  while (str.isNotEmpty) {
    var l = 0;
    if (str.length > 8) {
      l = str.length - 8;
    }
    var temp = int.parse(str.substring(l), radix: 2);
    result.insert(0, temp);
    if (l == 0) {
      break;
    } else {
      str = str.substring(0, l);
    }
  }

  return Uint8List.fromList(result);
}