disconnect method

Future disconnect({
  1. Duration? timeout,
})
override

timeout: milliseconds to wait after closing the socket

Implementation

Future disconnect({Duration? timeout}) async {
  try {
    if (Platform.isAndroid)
      await flutterPrinterChannel.invokeMethod('disconnect');
    else if (Platform.isIOS) await iosChannel.invokeMethod('disconnect');
  } catch (e) {
    return Future.error(e.toString());
  }
  if (timeout != null) {
    await Future.delayed(timeout, () => null);
  }
}