printBill method

Future<PrintResult> printBill({
  1. int width = 580,
  2. int height = 0,
})

Implementation

Future<PrintResult> printBill({
  int width = 580,
  int height = 0,
}) async {
  String? filePath;
  var count = 0;
  do {
    count++;
    filePath = await _captureWidget();
  } while (filePath == null && count < 5);

  if (filePath == null) {
    throw Exception('Error while capturing screenshot.');
  }

  return await posPrinter.print(
    filePath,
    width: width,
    height: height,
  );
}