Open nerahmou opened 1 year ago
I got this error sometimes when calling printer.rawBytes(buffer). Looking at the source code, I don't understand how socket has not been initialized if connect result is success.
Package code :
Future<PosPrintResult> connect(String host, {int port = 91000, Duration timeout = const Duration(seconds: 5)}) async { _host = host; _port = port; try { _socket = await Socket.connect(host, port, timeout: timeout); _socket.add(_generator.reset()); return Future<PosPrintResult>.value(PosPrintResult.success); } catch (e) { return Future<PosPrintResult>.value(PosPrintResult.timeout); } }
My code :
final PosPrintResult result = await _networkPrinter.connect(ipAddress, port: 9100); if (result == PosPrintResult.success) { _networkPrinter.rawBytes(_buffer); _networkPrinter.cut(); _networkPrinter.disconnect(); }
I got this error sometimes when calling printer.rawBytes(buffer). Looking at the source code, I don't understand how socket has not been initialized if connect result is success.
Package code :
My code :