I am using the Flutter package flutter_esc_printer: ^0.1.0 to print to a thermal receipt printer.
Normally I expect the printer will be connected by Ethernet but it gives the error SocketException: OS Error: Connection timed out, errno = 110, address = 192.19.170.13, port = 47763.
What I have tried:
this is my code-
Future<Ticket> testTicket(PaperSize paper) async {
final Ticket ticket = Ticket(paper);
uid = FirebaseAuth.instance.currentUser.uid;
areaRef=FirebaseDatabase.instance
.reference()
.child('Area')
.child(uid);
areaRef.once().then((DataSnapshot snapshot){
contactList .clear();
Map<dynamic, dynamic> values = snapshot.value;
values.forEach((key,values){
values["key"]=key;
contactList.add(values);
});
});
ticket.text(
"Area Details",
styles: PosStyles(align: PosAlign.center));
ticket.text('Kissan Accounting',
styles: PosStyles(align: PosAlign.center));
ticket.hr();
ticket.row([
PosColumn(
text: 'Area Name',
width: 2,
styles: PosStyles(align: PosAlign.left, bold: true)),
PosColumn(
text: 'Area/Unit',
width: 2,
styles: PosStyles(align: PosAlign.left, bold: true)),
PosColumn(
text: 'Source',
width: 3,
styles: PosStyles(align: PosAlign.center, bold: true)),
PosColumn(
text: 'IrrigatedType',
width: 3,
styles: PosStyles(align: PosAlign.center, bold: true)),
PosColumn(
text: 'Location',
width: 2,
styles: PosStyles(align: PosAlign.right, bold: true)),
]);
for(int i=0;i<contactList.length;i++)
ticket.row([
PosColumn(text: contactList[i]["areaname"], width: 2),
PosColumn(
text: contactList[i]["area"],
width: 2,
styles: PosStyles(
align: PosAlign.left,
)),
PosColumn(
text: contactList[i]["Source"],
width: 3,
styles: PosStyles(
align: PosAlign.center,
)),
PosColumn(text: contactList[i]["IrrigatedType"], width: 3, styles: PosStyles(align: PosAlign.center)),
PosColumn(text: contactList[i]["Location"], width: 2, styles: PosStyles(align: PosAlign.right)),
]);
ticket.hr(ch: '=', linesAfter: 1);
ticket.text('Thank you!',
styles: PosStyles(align: PosAlign.center, bold: true));
ticket.feed(2);
ticket.cut();
return ticket;
}
_testPrint() async {
const PaperSize paper = PaperSize.mm80;
String address = "192.168.0.111";
if(address.isIpAddress){
_printerNetworkManager.selectPrinter(address);
final res = await _printerNetworkManager.printTicket(await testTicket(paper));
}else if(address.isMacAddress) {
_printerBluetoothManager.selectPrinter(address);
final res = await _printerBluetoothManager.printTicket(await testTicket(paper));
}else{
print("Error :e");
}
}