getConnectedPrinter method

  1. @override
Future<BrotherPrinter?> getConnectedPrinter()
override

Returns the printer currently connected, or null when none.

The logical connection stored by connect is kept until disconnect is called (or the plugin is detached), even if the caller navigates to another screen. This is the data needed to print again without re-running discovery — useful because a printer that was connected without a proper disconnect is often "busy" and no longer listed by the discovery.

Implementation

@override
Future<BrotherPrinter?> getConnectedPrinter() async {
  final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
    'getConnectedPrinter',
  );
  if (result == null) return null;
  return BrotherPrinter.fromMap(result);
}