BtcByteStreamReader extension Models

Serial-friendly reading helpers on a byte stream such as BtcConnection.input or BtcReconnectingConnection.input.

on

Methods

decoded({Encoding encoding = utf8}) → Stream<String>

Available on Stream<Uint8List>, provided by the BtcByteStreamReader extension

Decodes incoming bytes to text as they arrive, correctly handling multi-byte characters split across chunk boundaries. Not line-buffered.
frames({List<int> delimiter = const [0x0A], int? maxFrameLength}) → Stream<Uint8List>

Available on Stream<Uint8List>, provided by the BtcByteStreamReader extension

Splits this stream into delimiter-separated frames (delimiter stripped), reassembling frames that span multiple chunks. See BtcFrameSplitter.
lengthFrames({int prefixLength = 1, bool bigEndian = true, bool lengthIncludesPrefix = false, int? maxFrameLength}) → Stream<Uint8List>

Available on Stream<Uint8List>, provided by the BtcByteStreamReader extension

Splits this stream into frames that each begin with their own length (the prefix stripped), reassembling frames that span multiple chunks. See BtcLengthFrameSplitter, which is the one to use for a binary protocol whose payload bytes could take any value.
lines({Encoding encoding = utf8, int? maxLineLength}) → Stream<String>

Available on Stream<Uint8List>, provided by the BtcByteStreamReader extension

Emits decoded text lines. Splits on \n, strips a trailing \r so both \n- and \r\n-terminated devices read cleanly, and decodes each line with encoding (UTF-8 by default).