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
aa490654
Commit
aa490654
authored
Jan 15, 2020
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added printing timeout
parent
b2d5632d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
main.dart
example/blue/lib/main.dart
+10
-2
No files found.
example/blue/lib/main.dart
View file @
aa490654
...
...
@@ -74,11 +74,12 @@ class _MyHomePageState extends State<MyHomePage> {
bluetoothManager
.
stopScan
();
}
Future
_
sleep
(
int
seconds
)
{
Future
_
runDelayed
(
int
seconds
)
{
return
Future
<
dynamic
>.
delayed
(
Duration
(
seconds:
seconds
));
}
void
_testPrint
(
BluetoothDevice
printer
)
async
{
const
int
timeout
=
5
;
if
(
_isScanning
)
{
// print('Print failed (scanning in progress)');
showToast
(
'Print failed (scanning in progress)'
);
...
...
@@ -112,7 +113,7 @@ class _MyHomePageState extends State<MyHomePage> {
showToast
(
'Data sent'
);
}
// TODO sending disconnect signal should be event-based
_
sleep
(
3
).
then
((
dynamic
printer
)
async
{
_
runDelayed
(
3
).
then
((
dynamic
v
)
async
{
print
(
'@@@@DISCONNECTING......'
);
await
bluetoothManager
.
disconnect
();
_isPrinting
=
false
;
...
...
@@ -127,6 +128,13 @@ class _MyHomePageState extends State<MyHomePage> {
break
;
}
});
// Printing timeout
_runDelayed
(
timeout
).
then
((
dynamic
v
)
async
{
if
(
_isPrinting
)
{
_isPrinting
=
false
;
showToast
(
'Print failed'
);
}
});
}
@override
...
...
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