printReceipt method

  1. @override
Future<bool> printReceipt(
  1. String identifier,
  2. String interfaceType,
  3. Map<String, dynamic> printData
)
override

Prints a receipt on a specified printer using the provided print data.

  • identifier: A unique identifier for the printer.
  • interfaceType: The connection interface type (e.g., USB, Bluetooth).
  • printData: The data to be printed on the receipt.

Returns a Future containing a bool indicating whether the print operation was successful.

Implementation

@override
Future<bool> printReceipt(String identifier, String interfaceType,
    Map<String, dynamic> printData) async {
  try {
    final bool result =
        await methodChannel.invokeMethod<bool>('printReceipt', {
              "identifier": identifier,
              "interfaceType": interfaceType,
              "printData": printData, // Pass the data for the receipt
            }) ??
            false;

    return result;
  } catch (e) {
    debugPrint("Error printing document: $e");
    return false;
  }
}