BtcFrameSplitter class Models
Splits a byte stream into frames separated by a delimiter, buffering across chunk boundaries so a frame may span several reads. The delimiter is stripped from the emitted frames.
RFCOMM (like any stream transport) does not preserve message boundaries. A
single input event may contain part of a line, several lines, or a line
split mid-way. This transformer reassembles delimiter-terminated frames.
connection.input
.transform(const BtcFrameSplitter()) // default delimiter: '\n'
.listen((frame) => print('line: ${utf8.decode(frame)}'));
A trailing, un-terminated remainder is not emitted. Framing waits for the delimiter. If maxFrameLength is set and the buffer grows past it before a delimiter arrives, the stream emits a StateError and drops the buffer (a guard against a missing delimiter growing memory without bound).
- Inheritance
-
- Object
- StreamTransformerBase<
Uint8List, Uint8List> - BtcFrameSplitter
Constructors
-
BtcFrameSplitter({List<
int> delimiter = const [0x0A], int? maxFrameLength}) -
Creates a splitter that breaks input on
delimiter(default:\n).const
Properties
-
delimiter
→ List<
int> -
The byte sequence that separates frames.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxFrameLength → int?
-
Optional cap on the buffered (un-terminated) bytes before erroring.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
bind(
Stream< Uint8List> stream) → Stream<Uint8List> -
Transforms the provided
stream.override -
cast<
RS, RT> () → StreamTransformer< RS, RT> -
Provides a
StreamTransformer<RS, RT>view of this stream transformer.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited