connect method
connect let you connect to a network printer
Implementation
Future<ConnectionResponse> connect(
{Duration? timeout: const Duration(seconds: 5)}) async {
try {
this.socket = await Socket.connect(address, port, timeout: timeout);
this.isConnected = true;
this.printer.connected = true;
return Future<ConnectionResponse>.value(ConnectionResponse.success);
} catch (e) {
this.isConnected = false;
this.printer.connected = false;
return Future<ConnectionResponse>.value(ConnectionResponse.timeout);
}
}