connect method
connect() takes the name of a discovered printer and the protocol to connect over and attempts to connect the mobile device to the printer.
@param printer is a string representing the name of the printer to connect to. @param connectWithBluetooth is a bool representing the protocol to connect over. true: search for a printer discovered over bluetooth with the matching name. false: search for a printer discovered over Wi-Fi network with the matching name. null: ignores protocol and connects to any printer matching the name.
@returns a bool representing the connection result.
Implementation
@override
Future<bool?> connect(String? printer, bool? connectWithBluetooth) async {
var sendMap = <String, dynamic>{
"printerName": printer,
"connectWithBluetooth": connectWithBluetooth
};
bool? connected =
await methodChannel.invokeMethod<bool>('connect', sendMap);
return connected;
}