toPosPrinter method

Future<List<Uint8List>> toPosPrinter(
  1. BuildContext context, {
  2. int maxHeight = 2000,
  3. double? maxWidth,
  4. int margin = 0,
  5. double fixedRatio = 0,
})

Converte o DANFE em uma lista de partes de imagem para impressoras POS.

Automaticamente divide recibos longos em chunks para impressão.

Parâmetros:

  • context: BuildContext necessário para renderização.
  • maxHeight: Altura máxima por chunk de imagem. Padrão é 2000.
  • maxWidth: Largura máxima das imagens. Se não fornecido, usa a largura do papel.
  • margin: Margem horizontal. Padrão é 0.
  • fixedRatio: Proporção fixa para qualidade da imagem.

Retorno:

  • Um Future<List<Uint8List>> contendo as partes da imagem para impressão.

Exemplo:

List<Uint8List> imageParts = await imageDanfe.toPosPrinter(context);
for (var part in imageParts) {
  await printer.printImage(part);
}

Implementation

Future<List<Uint8List>> toPosPrinter(
  BuildContext context, {
  int maxHeight = 2000,
  double? maxWidth,
  int margin = 0,
  double fixedRatio = 0,
}) async {
  return await _printerGateway.toPosPrinter(
    context,
    maxHeight: maxHeight,
    maxWidth: maxWidth ?? paperSize.maxWidth,
    margin: margin,
    fixedRatio: fixedRatio,
  );
}