Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esc_pos_print_plus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
esc_pos_print_plus
Commits
37f9dfd6
Commit
37f9dfd6
authored
Sep 02, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Flutter example for image printing
parent
bc179e94
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
logo.png
example/discover_printers/assets/logo.png
+0
-0
main.dart
example/discover_printers/lib/main.dart
+11
-2
pubspec.yaml
example/discover_printers/pubspec.yaml
+3
-4
No files found.
example/discover_printers/assets/logo.png
0 → 100644
View file @
37f9dfd6
2.33 KB
example/discover_printers/lib/main.dart
View file @
37f9dfd6
import
'package:flutter/material.dart'
;
import
'dart:typed_data'
;
import
'package:flutter/material.dart'
hide
Image
;
import
'package:esc_pos_printer/esc_pos_printer.dart'
;
import
'package:flutter/services.dart'
;
import
'package:ping_discover_network/ping_discover_network.dart'
;
import
'package:image/image.dart'
;
import
'package:wifi/wifi.dart'
;
void
main
(
)
=>
runApp
(
MyApp
());
...
...
@@ -87,7 +90,7 @@ class _MyHomePageState extends State<MyHomePage> {
void
testPrint
(
String
printerIp
,
BuildContext
ctx
)
{
Printer
.
connect
(
printerIp
,
port:
int
.
parse
(
portController
.
text
),
timeout:
Duration
(
seconds:
5
))
.
then
((
printer
)
{
.
then
((
printer
)
async
{
printer
.
println
(
'Normal text'
);
printer
.
println
(
'Bold text'
,
styles:
PosStyles
(
bold:
true
));
printer
.
println
(
'Reverse text'
,
styles:
PosStyles
(
reverse:
true
));
...
...
@@ -124,6 +127,12 @@ class _MyHomePageState extends State<MyHomePage> {
width:
PosTextSize
.
size2
,
));
// Print image
final
ByteData
data
=
await
rootBundle
.
load
(
'assets/logo.png'
);
final
Uint8List
bytes
=
data
.
buffer
.
asUint8List
();
final
Image
image
=
decodeImage
(
bytes
);
printer
.
printImage
(
image
);
printer
.
cut
();
printer
.
disconnect
();
...
...
example/discover_printers/pubspec.yaml
View file @
37f9dfd6
...
...
@@ -21,6 +21,7 @@ dependencies:
sdk
:
flutter
wifi
:
^0.1.5
ping_discover_network
:
^0.1.2
image
:
^2.1.4
esc_pos_printer
:
path
:
../../
...
...
@@ -44,10 +45,8 @@ flutter:
# the material Icons class.
uses-material-design
:
true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets
:
-
assets/logo.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment