我正在尝试使用网络打印机在 flutter 中打印列之间有空格的列,但问题是它显示没有空格的列

问题描述 投票:0回答:1
*printing columns inside row using network printer*

这是我使用的代码

import 'package:esc_pos_printer/esc_pos_printer.dart';
import 'package:esc_pos_utils/esc_pos_utils.dart';

printItem() async {
  const PaperSize paper = PaperSize.mm80;

  final profile = await CapabilityProfile.load();
  final printer = NetworkPrinter(paper, profile, spaceBetweenRows: 30);

  final PosPrintResult res =
      await printer.connect('192.168.100.30', port: 9100);

  if (res == PosPrintResult.success) {
    printer.row([
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);
    printer.row([
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);
    printer.feed(2);
    printer.cut();
    printer.disconnect();
    print('Print result: ${res.msg}');
  }
}

代码的结果: enter image description here 这是一个我使用过的依赖项的链接: 在此输入链接描述 这是列的预期结果: enter image description here

flutter dart flutter-dependencies network-printers
1个回答
0
投票
printer.row([
 PosColumn(
        text: '',
        width: 2,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
 PosColumn(
        text: '',
        width: 2, #As your width size
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col6',
        width: 6,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
PosColumn(
        text: '',
        width: 2,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
      PosColumn(
        text: 'col3',
        width: 3,
        styles: PosStyles(align: PosAlign.center, underline: true),
      ),
    ]);
© www.soinside.com 2019 - 2024. All rights reserved.