connectToPrinter method

Future<bool?> connectToPrinter(
  1. String ipAddress,
  2. String port
)

Establishes a WiFi connection to the printer at ipAddress:port.

Returns true on success. Throws a descriptive string on failure.

Implementation

Future<bool?> connectToPrinter(String ipAddress, String port) async {
  try {
    final bool? result = await _channel.invokeMethod('connectToPrinter', {
      'ipAddress': ipAddress,
      'port': port,
    });
    return result;
  } on PlatformException catch (e) {
    throw 'Failed to connect to printer: ${e.message}';
  }
}