colAuto method

PosColumn colAuto(
  1. dynamic value,
  2. int width, {
  3. ReceiptTextType type = ReceiptTextType.text,
  4. FontSize size = FontSize.normal,
  5. bool bold = false,
  6. PosAlign align = PosAlign.left,
})

Implementation

PosColumn colAuto(
  dynamic value,
  int width, {
  ReceiptTextType type = ReceiptTextType.text,
  FontSize size = FontSize.normal,
  bool bold = false,
  PosAlign align = PosAlign.left,
}) {
  String text;

  if (type == ReceiptTextType.money) {
    if (value is num) {
      text = formatMoney(value);
    } else {
      text = value.toString();
    }
    align = PosAlign.right; // money selalu kanan
  } else {
    text = value.toString();
  }

  return PosColumn(
    text: text,
    width: width,
    styles: ThermalFontMapper.style(
      size,
      bold: bold,
      align: align,
    ),
  );
}