ImageDanfe class
Classe responsável por converter dados do DANFE em diferentes formatos de saída
utilizando o pacote printer_gateway.
Responsabilidades:
- Converter JSON do DANFE em Widget Flutter para visualização.
- Gerar imagens a partir do JSON do DANFE.
- Exportar para formatos compatíveis com impressoras POS e ESC/POS.
Exemplo de uso:
final danfePrinter = DanfePrinter(PaperSize.mm80);
final jsonData = danfePrinter.normativeJsonDanfe(danfe);
final imageDanfe = ImageDanfe(
jsonData: jsonData,
paperSize: DanfePaperSize.mm80,
);
// Obter Widget para visualização
Widget widget = imageDanfe.toWidget();
// Gerar imagem
Uint8List image = await imageDanfe.toImage(context);
Constructors
- ImageDanfe({required String jsonData, DanfePaperSize paperSize = DanfePaperSize.mm80, Uint8List? headerImage, })
- Construtor da classe ImageDanfe.
- ImageDanfe.fromDanfe({required Danfe danfe, DanfePaperSize paperSize = DanfePaperSize.mm80, bool mostrarMoeda = true, Uint8List? headerImage, String? customFont})
-
Construtor de fábrica para criar ImageDanfe diretamente de um objeto Danfe.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- jsonData → String
-
JSON string contendo os dados do DANFE no formato do printer_gateway.
final
- paperSize → DanfePaperSize
-
Tamanho do papel para impressão.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
- Adiciona uma imagem de rodapé ao DANFE.
-
addHeaderImage(
Uint8List imageBytes) → void - Adiciona uma imagem de cabeçalho ao DANFE.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toEscPosPrinter(
BuildContext context, {int maxHeight = 2000, double? maxWidth, int margin = 0, double fixedRatio = 0}) → Future< List< Image> > - Converte o DANFE em uma lista de imagens decodificadas para impressoras ESC/POS.
-
toImage(
BuildContext context, {double? maxWidth, int margin = 0, double fixedRatio = 0}) → Future< Uint8List> - Gera uma imagem (Uint8List) a partir do JSON do DANFE.
-
toPosPrinter(
BuildContext context, {int maxHeight = 2000, double? maxWidth, int margin = 0, double fixedRatio = 0}) → Future< List< Uint8List> > - Converte o DANFE em uma lista de partes de imagem para impressoras POS.
-
toString(
) → String -
A string representation of this object.
inherited
-
toWidget(
{double? maxWidth, int margin = 0}) → Widget - Converte o JSON do DANFE em um Widget Flutter para visualização.
-
updateData(
String newJsonData) → void - Atualiza os dados do JSON do DANFE.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited