Commit f5df6da8 authored by Dio Maulana's avatar Dio Maulana

Initial commit

parents
{
"configVersion": 2,
"packages": [
{
"name": "archive",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.9",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "async",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "boolean_selector",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "characters",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "clock",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "collection",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.2",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "convert",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/convert-3.1.1",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "crypto",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/crypto-3.0.3",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "csslib",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/csslib-1.0.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "fake_async",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "flutter",
"rootUri": "file:///C:/flutter/packages/flutter",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "flutter_test",
"rootUri": "file:///C:/flutter/packages/flutter_test",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "hex",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/hex-0.2.0",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "html",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/html-0.15.4",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "image",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/image-4.1.3",
"packageUri": "lib/",
"languageVersion": "2.15"
},
{
"name": "js",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.7",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "matcher",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.16",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "material_color_utilities",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "meta",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.9.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.3",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "petitparser",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/petitparser-5.4.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "pointycastle",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.3",
"packageUri": "lib/",
"languageVersion": "2.14"
},
{
"name": "sky_engine",
"rootUri": "file:///C:/flutter/bin/cache/pkg/sky_engine",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "source_span",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.10.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stack_trace",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "stream_channel",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1",
"packageUri": "lib/",
"languageVersion": "2.14"
},
{
"name": "string_scanner",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "term_glyph",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "test_api",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.6.0",
"packageUri": "lib/",
"languageVersion": "2.18"
},
{
"name": "typed_data",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/typed_data-1.3.2",
"packageUri": "lib/",
"languageVersion": "2.17"
},
{
"name": "vector_math",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4",
"packageUri": "lib/",
"languageVersion": "2.14"
},
{
"name": "web",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/web-0.1.4-beta",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "xml",
"rootUri": "file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/xml-6.3.0",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "esc_pos_utils_plus",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "2.16"
}
],
"generated": "2023-11-09T09:27:40.174069Z",
"generator": "pub",
"generatorVersion": "3.1.5"
}
archive
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.9/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/archive-3.4.9/lib/
async
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.11.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/async-2.11.0/lib/
boolean_selector
2.17
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/boolean_selector-2.1.1/lib/
characters
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/characters-1.3.0/lib/
clock
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/clock-1.1.1/lib/
collection
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.2/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/collection-1.17.2/lib/
convert
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/convert-3.1.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/convert-3.1.1/lib/
crypto
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/crypto-3.0.3/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/crypto-3.0.3/lib/
csslib
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/csslib-1.0.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/csslib-1.0.0/lib/
fake_async
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1/lib/
hex
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/hex-0.2.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/hex-0.2.0/lib/
html
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/html-0.15.4/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/html-0.15.4/lib/
image
2.15
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/image-4.1.3/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/image-4.1.3/lib/
js
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.7/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/js-0.6.7/lib/
matcher
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.16/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/matcher-0.12.16/lib/
material_color_utilities
2.17
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/material_color_utilities-0.5.0/lib/
meta
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.9.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/meta-1.9.1/lib/
path
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.3/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/path-1.8.3/lib/
petitparser
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/petitparser-5.4.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/petitparser-5.4.0/lib/
pointycastle
2.14
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.3/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.3/lib/
source_span
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.10.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/source_span-1.10.0/lib/
stack_trace
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stack_trace-1.11.0/lib/
stream_channel
2.14
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/stream_channel-2.1.1/lib/
string_scanner
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/string_scanner-1.2.0/lib/
term_glyph
2.12
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/term_glyph-1.2.1/lib/
test_api
2.18
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.6.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/test_api-0.6.0/lib/
typed_data
2.17
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/typed_data-1.3.2/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/typed_data-1.3.2/lib/
vector_math
2.14
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/vector_math-2.1.4/lib/
web
3.1
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/web-0.1.4-beta/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/web-0.1.4-beta/lib/
xml
2.19
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/xml-6.3.0/
file:///C:/Users/Asrock%20B560M%20Pro4/AppData/Local/Pub/Cache/hosted/pub.dev/xml-6.3.0/lib/
sky_engine
3.0
file:///C:/flutter/bin/cache/pkg/sky_engine/
file:///C:/flutter/bin/cache/pkg/sky_engine/lib/
flutter
3.0
file:///C:/flutter/packages/flutter/
file:///C:/flutter/packages/flutter/lib/
flutter_test
3.0
file:///C:/flutter/packages/flutter_test/
file:///C:/flutter/packages/flutter_test/lib/
esc_pos_utils_plus
2.16
file:///D:/Developer/project/Kantor%20Ravintola/Flutter/esc_pos_utils_plus/
file:///D:/Developer/project/Kantor%20Ravintola/Flutter/esc_pos_utils_plus/lib/
2
3.13.9
\ No newline at end of file
## [2.0.2]
- support flutter v 3.10.0
## [2.0.1+6]
- pre-cache capabilities
## [2.0.1+5]
- add paper size mm72 by keep mm80 as 576
## [2.0.1+4]
- change paper size width back from 576 to 558
## [2.0.1+3]
- change paper size width from 372 to 384 and 558 to 576
## [2.0.1+2]
- hotfix resource
## [2.0.1+1]
- hotfix resource
## [2.0.1]
- included gbk_codec directly
## [2.0.0]
- nullable implemented
## [1.0.0]
- `Ticket` class replaced by `Generator`.
- New code generation concept: Unlike `Ticket`, each method returns corresponding command's byte code
## [0.4.9]
- Xprinter profile: added cp1258 (vietnamese)
## [0.4.8]
- Replace some non-ascii characters
## [0.4.7]
- Printing a long text col splits the data to the next row (case when col contains chinese characters taking 2 bytes)
## [0.4.6]
- Bug fix: printing a long text col splits the data to the next row
- Ticket class : added named parameter `spaceBetweenRows`
## [0.4.5]
- Updated example and README (using CapabilityProfiles)
## [0.4.4]
- Setting code page before printing to support some printer models
## [0.4.3]
- Set Kanji mode 0ff before setting a code page to support some printer models
## [0.4.2]
- Update printer profiles
## [0.4.1]
- Using flutter assets to load capabilities.json
## [0.4.0]
- PosCodeTable replaced by CapabilitiesProfile
## [0.3.7]
- Fixed merged text on some printers when using chinese + latin together in one string
## [0.3.6]
- Print QR Codes using native function
## [0.3.5]
- Added `Ticket.setGlobalFont` method
- `Ticket.codeTable` renamed to `Ticket.printCodeTable`
- Added `maxCharsPerLine` custom config + default values depending on current font and ticket size
- Code refactoring
## [0.3.4]
- Added hr method
- Updated commands (using hex codes)
- setStyles bug fix
## [0.3.3]
- Slow printing issue on some printer models fixed
## [0.3.2]
- `PosColumn` can contain encoded text (`textEncoded` field)
- Bug fix: Columns with `PosTextSize` > `size1`
- Added Barcode Code128
- Added new code pages
- `imageRaster` bug fixed
- Ticket bytecode optimization: do not generate align left command (it's a default value)
- Added new image print function: `GS ( L`
## [0.3.1]
- Added Open cash drawer command
## [0.3.0]
- Image alignment (left, center, right). Align center by default.
- Barcode alignment (left, center, right). Align center by default.
- `PosTextAlign` renamed to `PosAlign`
## [0.2.0]
- `Ticket._text` function takes an Uint8List of bytes instead of a String
- `Ticket._text` function refactored: removed styling commands when it's unnecessary which makes ticket's final byte code much shorter
- `PosCodeTable`: private constructor replaced by public one to allow passing custom code table code
- `PosCodeTable`: added new predefined code tables
- Added `Ticket.textEncoded` function taking Uint8List textBytes (encoded text) to support different languages
## [0.1.0 - 0.1.2]
- Initial release
Copyright (c) 2020 Andrey U. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
# esc_pos_utils
[![Pub Version](https://img.shields.io/pub/v/esc_pos_utils)](https://pub.dev/packages/esc_pos_utils)
Base Flutter/Dart classes for ESC/POS printing. `Generator` class generates ESC/POS commands that can be sent to a thermal printer.
This is the "base" library that used for:
- Flutter WiFi/Ethernet printing: [esc_pos_printer](https://github.com/andrey-ushakov/esc_pos_printer)
- Flutter Bluetooth printing: [esc_pos_bluetooth](https://github.com/andrey-ushakov/esc_pos_bluetooth)
## Main Features
- Connect to Wi-Fi / Ethernet printers
- Simple text printing using _text_ method
- Tables printing using _row_ method
- Text styling:
- size, align, bold, reverse, underline, different fonts, turn 90°
- Print images
- Print barcodes
- UPC-A, UPC-E, JAN13 (EAN13), JAN8 (EAN8), CODE39, ITF (Interleaved 2 of 5), CODABAR (NW-7), CODE128
- Paper cut (partial, full)
- Beeping (with different duration)
- Paper feed, reverse feed
**Note**: Your printer may not support some of the presented features (some styles, partial/full paper cutting, reverse feed, barcodes...).
## Generate a Ticket
### Simple ticket with styles:
```dart
List<int> testTicket() {
final List<int> bytes = [];
// Using default profile
final profile = await CapabilityProfile.load();
final generator = Generator(PaperSize.mm80, profile);
List<int> bytes = [];
bytes += generator.text(
'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
bytes += generator.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: PosCodeTable.westEur));
bytes += generator.text('Special 2: blåbærgrød',
styles: PosStyles(codeTable: PosCodeTable.westEur));
bytes += generator.text('Bold text', styles: PosStyles(bold: true));
bytes += generator.text('Reverse text', styles: PosStyles(reverse: true));
bytes += generator.text('Underlined text',
styles: PosStyles(underline: true), linesAfter: 1);
bytes += generator.text('Align left', styles: PosStyles(align: PosAlign.left));
bytes += generator.text('Align center', styles: PosStyles(align: PosAlign.center));
bytes += generator.text('Align right',
styles: PosStyles(align: PosAlign.right), linesAfter: 1);
bytes += generator.text('Text size 200%',
styles: PosStyles(
height: PosTextSize.size2,
width: PosTextSize.size2,
));
bytes += generator.feed(2);
bytes += generator.cut();
return bytes;
}
```
### Print a table row:
```dart
generator.row([
PosColumn(
text: 'col3',
width: 3,
styles: PosStyles(align: PosAlign.center, underline: true),
),
PosColumn(
text: 'col6',
width: 6,
styles: PosStyles(align: PosAlign.center, underline: true),
),
PosColumn(
text: 'col3',
width: 3,
styles: PosStyles(align: PosAlign.center, underline: true),
),
]);
```
### Print an image:
This package implements 3 ESC/POS functions:
- `ESC *` - print in column format
- `GS v 0` - print in bit raster format (obsolete)
- `GS ( L` - print in bit raster format
Note that your printer may support only some of the above functions.
```dart
import 'dart:io';
import 'package:image/image.dart';
final ByteData data = await rootBundle.load('assets/logo.png');
final Uint8List bytes = data.buffer.asUint8List();
final Image image = decodeImage(bytes);
// Using `ESC *`
generator.image(image);
// Using `GS v 0` (obsolete)
generator.imageRaster(image);
// Using `GS ( L`
generator.imageRaster(image, imageFn: PosImageFn.graphics);
```
### Print a Barcode:
```dart
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
generator.barcode(Barcode.upcA(barData));
```
### Print a QR Code:
Using native ESC/POS commands:
```dart
generator.qrcode('example.com');
```
To print a QR Code as an image (if your printer doesn't support native commands), add [qr_flutter](https://pub.dev/packages/qr_flutter) and [path_provider](https://pub.dev/packages/path_provider) as a dependency in your `pubspec.yaml` file.
```dart
String qrData = "google.com";
const double qrSize = 200;
try {
final uiImg = await QrPainter(
data: qrData,
version: QrVersions.auto,
gapless: false,
).toImageData(qrSize);
final dir = await getTemporaryDirectory();
final pathName = '${dir.path}/qr_tmp.png';
final qrFile = File(pathName);
final imgFile = await qrFile.writeAsBytes(uiImg.buffer.asUint8List());
final img = decodeImage(imgFile.readAsBytesSync());
generator.image(img);
} catch (e) {
print(e);
}
```
## Using Code Tables
Different printers support different sets of code tables. Some printer models are defined in `CapabilityProfile` class. So, if you want to change the default code table, it's important to choose the right profile:
```dart
// Xprinter XP-N160I
final profile = await CapabilityProfile.load('XP-N160I');
final generator = Generator(PaperSize.mm80, profile);
bytes += generator.setGlobalCodeTable('CP1252');
```
All available profiles can be retrieved by calling :
```dart
final profiles = await CapabilityProfile.getAvailableProfiles();
```
## How to Help
- Add a CapabilityProfile to support your printer's model. A new profile should be added to `lib/resources/capabilities.json` file
- Test your printer and add it in the table: [Wifi/Network printer](https://github.com/andrey-ushakov/esc_pos_printer/blob/master/printers.md) or [Bluetooth printer](https://github.com/andrey-ushakov/esc_pos_bluetooth/blob/master/printers.md)
- Test and report bugs
- Share your ideas about what could be improved (code optimization, new features...)
import 'package:image/image.dart';
import 'dart:typed_data';
import 'package:flutter/services.dart';
import 'package:esc_pos_utils_plus/esc_pos_utils.dart';
Future<void> main() async {
final profile = await CapabilityProfile.load();
final generator = Generator(PaperSize.mm80, profile);
List<int> bytes = [];
bytes += generator.text(
'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
bytes += generator.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: 'CP1252'));
bytes += generator.text('Special 2: blåbærgrød',
styles: PosStyles(codeTable: 'CP1252'));
bytes += generator.text('Bold text', styles: PosStyles(bold: true));
bytes += generator.text('Reverse text', styles: PosStyles(reverse: true));
bytes += generator.text('Underlined text',
styles: PosStyles(underline: true), linesAfter: 1);
bytes +=
generator.text('Align left', styles: PosStyles(align: PosAlign.left));
bytes +=
generator.text('Align center', styles: PosStyles(align: PosAlign.center));
bytes += generator.text('Align right',
styles: PosStyles(align: PosAlign.right), linesAfter: 1);
bytes += generator.row([
PosColumn(
text: 'col3',
width: 3,
styles: PosStyles(align: PosAlign.center, underline: true),
),
PosColumn(
text: 'col6',
width: 6,
styles: PosStyles(align: PosAlign.center, underline: true),
),
PosColumn(
text: 'col3',
width: 3,
styles: PosStyles(align: PosAlign.center, underline: true),
),
]);
bytes += generator.text('Text size 200%',
styles: PosStyles(
height: PosTextSize.size2,
width: PosTextSize.size2,
));
// Print image:
final ByteData data = await rootBundle.load('assets/logo.png');
final Uint8List imgBytes = data.buffer.asUint8List();
final Image image = decodeImage(imgBytes)!;
bytes += generator.image(image);
// Print image using an alternative (obsolette) command
// bytes += generator.imageRaster(image);
// Print barcode
final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
bytes += generator.barcode(Barcode.upcA(barData));
// Print mixed (chinese + latin) text. Only for printers supporting Kanji mode
// ticket.text(
// 'hello ! 中文字 # world @ éphémère &',
// styles: PosStyles(codeTable: PosCodeTable.westEur),
// containsChinese: true,
// );
bytes += generator.feed(2);
bytes += generator.cut();
}
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
library esc_pos_utils;
export './gbk_codec/gbk_codec.dart';
export './src/barcode.dart';
export './src/capability_profile.dart';
export './src/enums.dart';
export './src/pos_column.dart';
export './src/pos_styles.dart';
export './src/qrcode.dart';
export './src/generator.dart';
\ No newline at end of file
/// GBK converter library
/// GBK codec converter (enCode and deCode) library includes bytes codec.
///
library gbk_codec;
export 'src/converter_gbk_byte.dart' show gbk_bytes;
export 'src/converter_gbk.dart' show gbk;
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
import 'dart:convert';
import 'gbk_maps.dart';
gbkCodec gbk = gbkCodec();
Map<int, String> _gbkCode_to_char = {};
Map<String, int> _char_to_gbkCode = {};
class gbkCodec extends Encoding {
@override
Converter<List<int>, String> get decoder => const gbkDecoder();
@override
Converter<String, List<int>> get encoder => const gbkEncoder();
@override
String get name => 'gbk';
gbkCodec() {
//initialize gbk code maps
_char_to_gbkCode = json_char_to_gbk;
json_gbk_to_char.forEach((sInt, sChar) {
_gbkCode_to_char[int.parse(sInt, radix: 16)] = sChar;
});
}
}
class gbkEncoder extends Converter<String, List<int>> {
const gbkEncoder();
@override
List<int> convert(String input) {
return gbkEncode(input);
}
}
List<int> gbkEncode(String input) {
var ret = <int>[];
input.codeUnits.forEach((charCode) {
var char = String.fromCharCode(charCode);
var gbkCode = _char_to_gbkCode[char];
if (gbkCode != null) {
ret.add(gbkCode);
} else if (charCode != null) {
ret.add(charCode);
}
});
return ret;
}
class gbkDecoder extends Converter<List<int>, String> {
const gbkDecoder();
@override
String convert(List<int> input) {
return gbkDecode(input);
}
}
String gbkDecode(List<int> input) {
var ret = '';
/*
List<int> combined = List<int>();
int id= 0;
while(id<input.length) {
int charCode = input[id];
id ++;
if (charCode < 0x80 || charCode > 0xffff || id == input.length) {
combined.add(charCode);
} else {
charCode = (charCode << 8) + input[id];
id ++;
combined.add(charCode);
}
}
*/
input.forEach((charCode) {
var char = _gbkCode_to_char[charCode];
if (char != null) {
ret += char;
} else {
ret += String.fromCharCode(charCode);
}
//print(ret);
});
return ret;
}
import 'dart:convert';
import 'gbk_maps.dart';
gbk_bytesCodec gbk_bytes = gbk_bytesCodec();
Map<int, String> _gbkCode_to_char = {};
Map<String, int> _char_to_gbkCode = {};
class gbk_bytesCodec extends Encoding {
@override
Converter<List<int>, String> get decoder => const gbk_bytesDecoder();
@override
Converter<String, List<int>> get encoder => const gbk_bytesEncoder();
@override
String get name => 'gbk_bytes';
gbk_bytesCodec(){
//initialize gbk code maps
_char_to_gbkCode = json_char_to_gbk;
json_gbk_to_char.forEach((sInt, sChar) {
_gbkCode_to_char[int.parse(sInt, radix : 16)] = sChar;
});
}
}
class gbk_bytesEncoder extends Converter<String, List<int>> {
const gbk_bytesEncoder();
@override
List<int> convert(String input) {
return gbk_bytesEncode(input);
}
}
List<int> gbk_bytesEncode(String input) {
var ret = <int>[];
input.codeUnits.forEach( (charCode) {
var char = String.fromCharCode(charCode);
//print(char);
var gbkCode = _char_to_gbkCode[char];
//print('$char = ${gbkCode.toRadixString(16)}');
if (gbkCode != null ) {
//split to two bytes
var a =(gbkCode >> 8) & 0xff;
var b = gbkCode & 0xff;
ret.add(a);
ret.add(b);
//print(' ${gbkCode.toRadixString(16)} -- ${a.toRadixString(16)} ${b.toRadixString(16)}');
}
else {
ret.add(charCode);
}
});
return ret;
}
class gbk_bytesDecoder extends Converter<List<int>, String> {
const gbk_bytesDecoder();
@override
String convert(List<int> input) {
return gbk_bytesDecode(input);
}
}
String gbk_bytesDecode(List<int> input) {
var ret = '';
var combined = <int>[];
var id= 0;
while(id<input.length) {
var charCode = input[id];
id ++;
if (charCode < 0x80 || charCode > 0xff || id == input.length) {
combined.add(charCode);
} else {
charCode = ((charCode)<< 8) + (input[id] & 0xff);
id ++;
combined.add(charCode);
}
}
combined.forEach((charCode) {
var char = _gbkCode_to_char[charCode];
if (char != null) {
ret += char;
} else {
ret += String.fromCharCode(charCode);
}
//print(ret);
});
return ret;
}
\ No newline at end of file
/*
file name: create_map
Function: preprocess, that create gbk map from standard data
The map data will be saved by json format
*/
//import 'dart:html';
import 'dart:convert';
import 'dart:io';
import 'package:html/dom.dart' as dom;
import 'body_element.dart';
Map<String, int>? gbkMap; // = new Map<String, int>(); //key is single length String
void main() async {
//key is single length String (character)
//value is codeUnit of GBK
//load html gbk data
var firstCode = <String>[] ; // = new List<String>();
await pageBody().then((dom.Element? bodySource) {
var lines = <String>[];
bodySource!.querySelectorAll('p').forEach((e) => lines.add(e.outerHtml));
for (var l in lines){
if (l.indexOf('0 1 2 3 4 5 6 7 8 9 A B C D E F') > 0){
l = l.replaceAll('0 1 2 3 4 5 6 7 8 9 A B C D E F', '');
l = l.replaceAll('&nbsp;', '');
firstCode.add(l);
print(l);
//print(l.indexOf('<p>AA <br>A'));
if (l.contains('<p>A9 <br>4')) {
print('---------break point----------------');
break;
} //last item
}
}
});
print(firstCode.length);
firstCode.forEach((s) => lineReader(s));
// check
gbkMap!.forEach((String char, int gbkCode){
print('$char gbkCode=${gbkCode.toRadixString(16)} unitCode:${char.codeUnitAt(0).toRadixString(16)}');
});
var sortChar = gbkMap!.keys.toList()..sort();
var sameKeys = <String>[];
var last = '\u0200';
sortChar.forEach((s) {
if (s == last) sameKeys.add(s);
last = s;
});
print(sameKeys.length);
var sortUnit = gbkMap!.values.toList()..sort();
var sameUnits = <int>[];
var lst = 9999;
sortUnit.forEach((i) {
if (i == lst) {
sameUnits.add(i);
print('--- find! ${lst.toRadixString(16)}');
}
lst = i;
});
print(sameUnits.length);
var look = int.parse('FE66', radix: 16);
var idn = sameUnits.where((i) => look==i);
print(idn);
//outputs
var json_char_to_gbk = jsonEncode(gbkMap);
final file1 = 'json_char_to_gbk.data';
await File(file1).writeAsString(json_char_to_gbk);
print(json_char_to_gbk);
print(gbkMap!.length);
var reversed_gbkMap = <String, String>{};
/*
gbkMap.forEach((s,i) {
reversed_gbkMap[i]=s;
});*/
gbkMap!.forEach((s,intS) {
reversed_gbkMap[intS.toRadixString(16)]=s[0];
});
var json_gbk_to_char = jsonEncode(reversed_gbkMap);
final file2 = 'json_gbk_to_char.data';
await File(file2).writeAsString(json_gbk_to_char);
print(reversed_gbkMap);
print(reversed_gbkMap.length);
//String json_gbk_to_char = jsonEncode(reversed_gbkMap);
print(json_gbk_to_char);
}
void lineReader(String line) {
String l, RD, TH;
var lastID = <String>['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
var firstByte = line.substring(3,5);
//print(firstByte);
print(line);
l = line.substring(10,line.length-4);
print(l);
var third = l.split('<br>');
//print(third);
third.forEach((String group) {
print(group);
var charList = group.split(' ');
print(charList);
RD = ascii09AF(charList[0]);
for(var i = 1; i<charList.length; i++) {
TH = lastID[i-1];
var hex = firstByte + RD + TH;
//print('${charList[i]} : $hex');
/*
Map<String, int> mNewword = new Map<String, int>();
mNewword[charList[i]] = int.parse(hex, radix: 16);
gbkMap.addAll(mNewword);*/
//gbkMap[charList[i]] = int.parse(hex, radix: 16); //unitCode
gbkMap!.putIfAbsent(charList[i], ()=> int.parse(hex, radix: 16));
print('"${charList[i]}" $hex = ${hex.codeUnitAt(0)} ${hex.codeUnitAt(1)} ${hex.codeUnitAt(2)} ${hex.codeUnitAt(3)} ');
}
});
}
String ascii09AF(String gbkChar) {
switch (gbkChar) {
case 'A': return 'A';
case 'B': return 'B';
case 'C': return 'C';
case 'D': return 'D';
case 'E': return 'E';
case 'F': return 'F';
case '0': return '0';
case '1': return '1';
case '2': return '2';
case '3': return '3';
case '4': return '4';
case '5': return '5';
case '6': return '6';
case '7': return '7';
case '8': return '8';
case '9': return '9';
default:
// do something else
}
return gbkChar;
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
class BarcodeType {
const BarcodeType._internal(this.value);
final int value;
/// UPC-A
static const upcA = BarcodeType._internal(0);
/// UPC-E
static const upcE = BarcodeType._internal(1);
/// JAN13 (EAN13)
static const ean13 = BarcodeType._internal(2);
/// JAN8 (EAN8)
static const ean8 = BarcodeType._internal(3);
/// CODE39
static const code39 = BarcodeType._internal(4);
/// ITF (Interleaved 2 of 5)
static const itf = BarcodeType._internal(5);
/// CODABAR (NW-7)
static const codabar = BarcodeType._internal(6);
/// CODE128
static const code128 = BarcodeType._internal(73);
}
class BarcodeText {
const BarcodeText._internal(this.value);
final int value;
/// Not printed
static const none = BarcodeText._internal(0);
/// Above the barcode
static const above = BarcodeText._internal(1);
/// Below the barcode
static const below = BarcodeText._internal(2);
/// Both above and below the barcode
static const both = BarcodeText._internal(3);
}
class BarcodeFont {
const BarcodeFont._internal(this.value);
final int value;
static const fontA = BarcodeFont._internal(0);
static const fontB = BarcodeFont._internal(1);
static const fontC = BarcodeFont._internal(2);
static const fontD = BarcodeFont._internal(3);
static const fontE = BarcodeFont._internal(4);
static const specialA = BarcodeFont._internal(97);
static const specialB = BarcodeFont._internal(98);
}
class Barcode {
/// UPC-A
///
/// k = 11, 12
/// d = '0' – '9'
Barcode.upcA(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (![11, 12].contains(k)) {
throw Exception('Barcode: Wrong data range');
}
final numeric = RegExp(r'^[0-9]$');
final bool isDataValid =
barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.upcA;
_data = _convertData(barcodeData);
}
/// UPC-E
///
/// k = 6 – 8, 11, 12
/// d = '0' – '9' (However, d0 = '0' when k = 7, 8, 11, 12)
Barcode.upcE(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (![6, 7, 8, 11, 12].contains(k)) {
throw Exception('Barcode: Wrong data range');
}
if ([7, 8, 11, 12].contains(k) && barcodeData[0].toString() != '0') {
throw Exception('Barcode: Data is not valid');
}
final numeric = RegExp(r'^[0-9]$');
final bool isDataValid =
barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.upcE;
_data = _convertData(barcodeData);
}
/// JAN13 (EAN13)
///
/// k = 12, 13
/// d = '0' – '9'
Barcode.ean13(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (![12, 13].contains(k)) {
throw Exception('Barcode: Wrong data range');
}
final numeric = RegExp(r'^[0-9]$');
final bool isDataValid =
barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.ean13;
_data = _convertData(barcodeData);
}
/// JAN8 (EAN8)
///
/// k = 7, 8
/// d = '0' – '9'
Barcode.ean8(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (![7, 8].contains(k)) {
throw Exception('Barcode: Wrong data range');
}
final numeric = RegExp(r'^[0-9]$');
final bool isDataValid =
barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.ean8;
_data = _convertData(barcodeData);
}
/// CODE39
///
/// k >= 1
/// d: '0'–'9', A–Z, SP, $, %, *, +, -, ., /
Barcode.code39(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (k < 1) {
throw Exception('Barcode: Wrong data range');
}
final regex = RegExp(r'^[0-9A-Z \$\%\*\+\-\.\/]$');
final bool isDataValid =
barcodeData.every((dynamic d) => regex.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.code39;
_data = _convertData(barcodeData);
}
/// ITF (Interleaved 2 of 5)
///
/// k >= 2 (even number)
/// d = '0'–'9'
Barcode.itf(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (k < 2 || !k.isEven) {
throw Exception('Barcode: Wrong data range');
}
final numeric = RegExp(r'^[0-9]$');
final bool isDataValid =
barcodeData.every((dynamic d) => numeric.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.itf;
_data = _convertData(barcodeData);
}
/// CODABAR (NW-7)
///
/// k >= 2
/// d: '0'–'9', A–D, a–d, $, +, −, ., /, :
/// However, d0 = A–D, dk = A–D (65-68)
/// d0 = a-d, dk = a-d (97-100)
Barcode.codabar(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (k < 2) {
throw Exception('Barcode: Wrong data range');
}
final regex = RegExp(r'^[0-9A-Da-d\$\+\-\.\/\:]$');
final bool isDataValid =
barcodeData.every((dynamic d) => regex.hasMatch(d.toString()));
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
if ((_charcode(barcodeData[0]) >= 65 && _charcode(barcodeData[0]) <= 68) &&
!(_charcode(barcodeData[k - 1]) >= 65 &&
_charcode(barcodeData[k - 1]) <= 68)) {
throw Exception('Barcode: Wrong data range');
}
if ((_charcode(barcodeData[0]) >= 97 && _charcode(barcodeData[0]) <= 100) &&
!(_charcode(barcodeData[k - 1]) >= 97 &&
_charcode(barcodeData[k - 1]) <= 100)) {
throw Exception('Barcode: Wrong data range');
}
_type = BarcodeType.codabar;
_data = _convertData(barcodeData);
}
/// CODE128
///
/// k >= 2
/// d: '{A'/'{B'/'{C' => '0'–'9', A–D, a–d, $, +, −, ., /, :
/// usage:
/// {A = QRCode type A
/// {B = QRCode type B
/// {C = QRCode type C
/// barcodeData ex.: "{A978020137962".split("");
Barcode.code128(List<dynamic> barcodeData) {
final k = barcodeData.length;
if (k < 2) {
throw Exception('Barcode: Wrong data range');
}
final regex = RegExp(r'^\{[A-C][\x00-\x7F]+$');
final bool isDataValid = regex.hasMatch(barcodeData.join());
if (!isDataValid) {
throw Exception('Barcode: Data is not valid');
}
_type = BarcodeType.code128;
_data = _convertData(barcodeData);
}
BarcodeType? _type;
List<int>? _data;
List<int> _convertData(List<dynamic> list) =>
list.map((dynamic d) => d.toString().codeUnitAt(0)).toList();
int _charcode(dynamic ch) => ch.toString().codeUnitAt(0);
BarcodeType? get type => _type;
List<int>? get data => _data;
}
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'dart:convert' show json;
import 'dart:convert' show utf8;
import 'package:flutter/services.dart' show rootBundle;
List<Map> printProfiles = [];
Map printCapabilities = {};
class CodePage {
CodePage(this.id, this.name);
int id;
String name;
}
class CapabilityProfile {
CapabilityProfile._internal(this.name, this.codePages);
/// [ensureProfileLoaded]
/// this method will cache the profile json into data which will
/// speed up the next loop and searching profile
static Future ensureProfileLoaded({String? path}) async {
/// check where this global capabilities is empty then load capabilities.json
/// else do nothing
if (printCapabilities.isEmpty == true) {
final content = await rootBundle.loadString(
path ?? 'packages/esc_pos_utils_plus/resources/capabilities.json');
var _capabilities = json.decode(content);
printCapabilities = Map.from(_capabilities);
(_capabilities['profiles'] as Map).forEach((k, v) {
printProfiles.add({
'key': k,
'vendor': v['vendor'] is String ? v['vendor'] : '',
'name': v['name'] is String ? v['name'] : '',
'description': v['description'] is String ? v['description'] : '',
});
});
/// assert that the capabilities will be not empty
assert(printCapabilities.isNotEmpty);
} else {
print("capabilities.length is already loaded");
}
}
/// Public factory
static Future<CapabilityProfile> load({String name = 'default'}) async {
///
await ensureProfileLoaded();
var profile = printCapabilities['profiles'][name];
if (profile == null) {
throw Exception("The CapabilityProfile '$name' does not exist");
}
List<CodePage> list = [];
(profile['codePages'] as Map).forEach((k, v) {
list.add(CodePage(int.parse(k), v));
});
// Call the private constructor
return CapabilityProfile._internal(name, list);
}
String name;
List<CodePage> codePages;
int getCodePageId(String? codePage) {
if (codePages.isEmpty) {
throw Exception("The CapabilityProfile isn't initialized");
}
return codePages
.firstWhere((cp) => cp.name == codePage,
// ignore: unnecessary_cast
orElse: (() => throw Exception(
"Code Page '$codePage' isn't defined for this profile"))
as CodePage Function()?)
.id;
}
static Future<List<dynamic>> getAvailableProfiles() async {
/// ensure the capabilities is not empty
await ensureProfileLoaded();
var _profiles = printCapabilities['profiles'] as Map;
List<dynamic> res = [];
_profiles.forEach((k, v) {
res.add({
'key': k,
'vendor': v['vendor'] is String ? v['vendor'] : '',
'name': v['name'] is String ? v['name'] : '',
'description': v['description'] is String ? v['description'] : '',
});
});
return res;
}
}
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
const esc = '\x1B';
const gs = '\x1D';
const fs = '\x1C';
// Miscellaneous
const cInit = '$esc@'; // Initialize printer
const cBeep = '${esc}B'; // Beeper [count] [duration]
// Mech. Control
const cCutFull = '${gs}V0'; // Full cut
const cCutPart = '${gs}V1'; // Partial cut
// Character
const cReverseOn = '${gs}B\x01'; // Turn white/black reverse print mode on
const cReverseOff = '${gs}B\x00'; // Turn white/black reverse print mode off
const cSizeGSn = '$gs!'; // Select character size [N]
const cSizeESCn = '$esc!'; // Select character size [N]
const cUnderlineOff = '$esc-\x00'; // Turns off underline mode
const cUnderline1dot = '$esc-\x01'; // Turns on underline mode (1-dot thick)
const cUnderline2dots = '$esc-\x02'; // Turns on underline mode (2-dots thick)
const cBoldOn = '${esc}E\x01'; // Turn emphasized mode on
const cBoldOff = '${esc}E\x00'; // Turn emphasized mode off
const cFontA = '${esc}M\x00'; // Font A
const cFontB = '${esc}M\x01'; // Font B
const cTurn90On = '${esc}V\x01'; // Turn 90° clockwise rotation mode on
const cTurn90Off = '${esc}V\x00'; // Turn 90° clockwise rotation mode off
const cCodeTable = '${esc}t'; // Select character code table [N]
const cKanjiOn = '$fs&'; // Select Kanji character mode
const cKanjiOff = '$fs.'; // Cancel Kanji character mode
// Print Position
const cAlignLeft = '${esc}a0'; // Left justification
const cAlignCenter = '${esc}a1'; // Centered
const cAlignRight = '${esc}a2'; // Right justification
const cPos = '$esc\$'; // Set absolute print position [nL] [nH]
// Print
const cFeedN = '${esc}d'; // Print and feed n lines [N]
const cReverseFeedN = '${esc}e'; // Print and reverse feed n lines [N]
// Bit Image
const cRasterImg = '$gs(L'; // Print image - raster bit format (graphics)
const cRasterImg2 =
'${gs}v0'; // Print image - raster bit format (bitImageRaster) [obsolete]
const cBitImg = '$esc*'; // Print image - column format
// Barcode
const cBarcodeSelectPos =
'${gs}H'; // Select print position of HRI characters [N]
const cBarcodeSelectFont = '${gs}f'; // Select font for HRI characters [N]
const cBarcodeSetH = '${gs}h'; // Set barcode height [N]
const cBarcodeSetW = '${gs}w'; // Set barcode width [N]
const cBarcodePrint = '${gs}k'; // Print barcode
// Cash Drawer Open
const cCashDrawerPin2 = '${esc}p030';
const cCashDrawerPin5 = '${esc}p130';
// QR Code
const cQrHeader = '$gs(k';
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
enum PosAlign { left, center, right }
enum PosCutMode { full, partial }
enum PosFontType { fontA, fontB }
enum PosDrawer { pin2, pin5 }
/// Choose image printing function
/// bitImageRaster: GS v 0 (obsolete)
/// graphics: GS ( L
enum PosImageFn { bitImageRaster, graphics }
class PosTextSize {
const PosTextSize._internal(this.value);
final int value;
static const size1 = PosTextSize._internal(1);
static const size2 = PosTextSize._internal(2);
static const size3 = PosTextSize._internal(3);
static const size4 = PosTextSize._internal(4);
static const size5 = PosTextSize._internal(5);
static const size6 = PosTextSize._internal(6);
static const size7 = PosTextSize._internal(7);
static const size8 = PosTextSize._internal(8);
static int decSize(PosTextSize height, PosTextSize width) =>
16 * (width.value - 1) + (height.value - 1);
}
class PaperSize {
const PaperSize._internal(this.value);
final int value;
static const mm58 = PaperSize._internal(1);
static const mm72 = PaperSize._internal(2);
static const mm80 = PaperSize._internal(3);
int get width {
if (value == PaperSize.mm58.value) {
return 384;
} else if (value == PaperSize.mm72.value) {
return 512;
} else {
return 576;
}
// value == PaperSize.mm58.value ? 384 : 558;
}
}
class PosBeepDuration {
const PosBeepDuration._internal(this.value);
final int value;
static const beep50ms = PosBeepDuration._internal(1);
static const beep100ms = PosBeepDuration._internal(2);
static const beep150ms = PosBeepDuration._internal(3);
static const beep200ms = PosBeepDuration._internal(4);
static const beep250ms = PosBeepDuration._internal(5);
static const beep300ms = PosBeepDuration._internal(6);
static const beep350ms = PosBeepDuration._internal(7);
static const beep400ms = PosBeepDuration._internal(8);
static const beep450ms = PosBeepDuration._internal(9);
}
This diff is collapsed.
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'dart:typed_data' show Uint8List;
import 'pos_styles.dart';
/// Column contains text, styles and width (an integer in 1..12 range)
/// [containsChinese] not used if the text passed as textEncoded
class PosColumn {
PosColumn({
this.text = '',
this.textEncoded,
this.containsChinese = false,
this.width = 2,
this.styles = const PosStyles(),
}) {
if (width < 1 || width > 12) {
throw Exception('Column width must be between 1..12');
}
if (text.isNotEmpty && textEncoded != null && textEncoded!.length > 0) {
throw Exception(
'Only one parameter - text or textEncoded - should be passed');
}
}
String text;
Uint8List? textEncoded;
bool containsChinese;
int width;
PosStyles styles;
}
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'enums.dart';
/// Text styles
class PosStyles {
const PosStyles({
this.bold = false,
this.reverse = false,
this.underline = false,
this.turn90 = false,
this.align = PosAlign.left,
this.height = PosTextSize.size1,
this.width = PosTextSize.size1,
this.fontType,
this.codeTable,
});
// Init all fields with default values
const PosStyles.defaults({
this.bold = false,
this.reverse = false,
this.underline = false,
this.turn90 = false,
this.align = PosAlign.left,
this.height = PosTextSize.size1,
this.width = PosTextSize.size1,
this.fontType = PosFontType.fontA,
this.codeTable = "CP437",
});
final bool bold;
final bool reverse;
final bool underline;
final bool turn90;
final PosAlign align;
final PosTextSize height;
final PosTextSize width;
final PosFontType? fontType;
final String? codeTable;
PosStyles copyWith({
bool? bold,
bool? reverse,
bool? underline,
bool? turn90,
PosAlign? align,
PosTextSize? height,
PosTextSize? width,
PosFontType? fontType,
String? codeTable,
}) {
return PosStyles(
bold: bold ?? this.bold,
reverse: reverse ?? this.reverse,
underline: underline ?? this.underline,
turn90: turn90 ?? this.turn90,
align: align ?? this.align,
height: height ?? this.height,
width: width ?? this.width,
fontType: fontType ?? this.fontType,
codeTable: codeTable ?? this.codeTable,
);
}
}
/*
* esc_pos_utils
* Created by Andrey U.
*
* Copyright (c) 2019-2020. All rights reserved.
* See LICENSE for distribution and usage details.
*/
import 'package:esc_pos_utils_plus/src/commands.dart';
import 'dart:convert';
class QRSize {
const QRSize(this.value);
final int value;
static const Size1 = QRSize(0x01);
static const Size2 = QRSize(0x02);
static const Size3 = QRSize(0x03);
static const Size4 = QRSize(0x04);
static const Size5 = QRSize(0x05);
static const Size6 = QRSize(0x06);
static const Size7 = QRSize(0x07);
static const Size8 = QRSize(0x08);
}
/// QR Correction level
class QRCorrection {
const QRCorrection._internal(this.value);
final int value;
/// Level L: Recovery Capacity 7%
static const L = QRCorrection._internal(48);
/// Level M: Recovery Capacity 15%
static const M = QRCorrection._internal(49);
/// Level Q: Recovery Capacity 25%
static const Q = QRCorrection._internal(50);
/// Level H: Recovery Capacity 30%
static const H = QRCorrection._internal(51);
}
class QRCode {
List<int> bytes = <int>[];
QRCode(String text, QRSize size, QRCorrection level) {
// FN 167. QR Code: Set the size of module
// pL pH cn fn n
bytes += cQrHeader.codeUnits + [0x03, 0x00, 0x31, 0x43] + [size.value];
// FN 169. QR Code: Select the error correction level
// pL pH cn fn n
bytes += cQrHeader.codeUnits + [0x03, 0x00, 0x31, 0x45] + [level.value];
// FN 180. QR Code: Store the data in the symbol storage area
List<int> textBytes = latin1.encode(text);
// pL pH cn fn m
bytes +=
cQrHeader.codeUnits + [textBytes.length + 3, 0x00, 0x31, 0x50, 0x30];
bytes += textBytes;
// FN 182. QR Code: Transmit the size information of the symbol data in the symbol storage area
// pL pH cn fn m
bytes += cQrHeader.codeUnits + [0x03, 0x00, 0x31, 0x52, 0x30];
// FN 181. QR Code: Print the symbol data in the symbol storage area
// pL pH cn fn m
bytes += cQrHeader.codeUnits + [0x03, 0x00, 0x31, 0x51, 0x30];
}
}
#DIBUAT KARNA ADA CUSTOM DI PRINTOUT
\ No newline at end of file
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.test"
minSdkVersion 16
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<application
android:label="test"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
package com.example.test
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
This diff is collapsed.
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
This diff is collapsed.
This diff is collapsed.
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment