onData method
Implementation
void onData(Uint8List data) {
if (_partial.length > maxLen) {
_partial = _partial.sublist(_partial.length - maxLen);
}
_partial.addAll(data);
while (((_partial.length - terminator!.length) > 0)) {
int index = wildcardFind(terminator, _partial);
if (index < 0) {
break;
}
Uint8List message;
if (stripTerminator) {
message = Uint8List.fromList(_partial.take(index).toList());
} else {
message = Uint8List.fromList(
_partial.take(index + terminator!.length).toList());
}
_controller.add(message);
_partial = _partial.sublist(index + terminator!.length);
}
}