watchConnectionState method

  1. @override
Stream<ConnectionState> watchConnectionState(
  1. BluetoothPrinter printer
)
override

Returns a stream of connection state updates for printer.

Implementation

@override
Stream<ConnectionState> watchConnectionState(
  BluetoothPrinter printer,
) async* {
  const period = Duration(seconds: 2);
  ConnectionState? last;
  while (true) {
    final state = await getConnectionState(printer);
    if (state != last) {
      last = state;
      yield state;
    }
    await Future<void>.delayed(period);
  }
}