DecoderEscPos class
Decodes ESC/POS commands from received print data, extracting text, formatting, and control instructions.
- Batch: decode (the whole data).
- Streaming: add chunks, then close.
- In lenient mode decoding never throws: unknown commands are emitted as CommandEscPosUnknown and a truncated command at the end of the data as CommandEscPosTruncated (see warnings). Otherwise (strict, default) a FormatException is thrown.
- Inheritance
-
- Object
- Decoder<
CommandEscPos> - DecoderEscPos
Constructors
- DecoderEscPos({bool lenient = false, EscPosTextDecoding textDecoding = EscPosTextDecoding.latin1, int defaultCodeTable = 0, bool detectUtf8 = false, int maxBarcodeDataLength = 255})
Properties
-
commands
→ List<
CommandEscPos> -
All decoded commands since the last reset.
no setter
- consumedBytes → int
-
The total of bytes consumed (decoded) since the last reset.
no setter
- defaultCodeTable → int
-
The code table (
ESC t n) used before anyESC tcommand, when textDecoding is EscPosTextDecoding.codeTable.final - detectUtf8 → bool
-
If
true, a text run with bytes>= 0x80that is valid UTF-8 is decoded as UTF-8.final - hashCode → int
-
The hash code for this object.
no setterinherited
- lenient → bool
-
If
truenever throws (see warnings).final - maxBarcodeDataLength → int
-
The maximum length of a NUL-terminated barcode data (
GS k m d1...dk NUL).final -
pendingBytes
→ List<
int> -
The bytes of an incomplete command waiting for more data (see add).
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- textDecoding → EscPosTextDecoding
-
How text bytes are decoded.
final
-
warnings
→ List<
DecoderWarning> -
The decoding warnings since the last reset.
no setter
Methods
-
add(
List< int> chunk) → List<CommandEscPos> -
Adds a
chunkof a data stream. A command split between chunks is decoded when its remaining bytes are added. Call close at the end. -
close(
) → List< CommandEscPos> - Ends a data stream (see add): flushes the pending text and handles an incomplete command at the end.
-
decode(
List< int> serial, {int offset = 0, int? length}) → List<CommandEscPos> -
Decodes the
serialdata (fromoffsetwithlength) as a complete block of data: a command truncated at the end is handled as CommandEscPosTruncated (lenient) or throws a FormatException.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
Resets the decoder state, preparing it for a new decoding process.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited