line static method

List<int> line({
  1. String typeLine = "-",
  2. FontSize fontSize = FontSize.normal,
})

Implementation

static List<int> line({String typeLine = "-", FontSize fontSize = FontSize.normal}) {
  String reset = '\x1B@';
  String enter = "\n";

  const cFontNormal = '\x1b\x4d\x00'; // Fuente estándar ASCII (2)
  const cFontCompressed = '\x1b\x4d\x01'; // Fuente comprimida
  const cDoubleHeightFont = '\x1d\x21\x11'; // Altura doblada
  const cDoubleWidthFont = '\x1d\x21\x22'; // Ancho doblado
  const cBigFont = '\x1d\x21\x33'; // Ancho y alto doblados
  const cTripleHeightFont = '\x1d\x21\x33'; // Altura doblada (5)

  //80 mm
  String fontSizeCode = "";
  int maxCaracteres = 48; //normal
  switch (fontSize) {
    case FontSize.compressed:
      maxCaracteres = 64;
      fontSizeCode = cFontCompressed;
      break;
    case FontSize.normal:
      maxCaracteres = 48;
      fontSizeCode = cFontNormal;
      break;
    case FontSize.doubleWidth:
      maxCaracteres = 32;
      fontSizeCode = cDoubleWidthFont;
      break;
    case FontSize.doubleHeight:
      maxCaracteres = 32;
      fontSizeCode = cDoubleHeightFont;
      break;
    case FontSize.big:
      maxCaracteres = 24;
      fontSizeCode = cBigFont;
      break;
    case FontSize.superBig:
      maxCaracteres = 16;
      fontSizeCode = cTripleHeightFont;
  }

  String textfinal = "$reset$fontSizeCode";
  for (int i = 0; i < maxCaracteres; i++) {
    textfinal += typeLine;
  }
  textfinal += enter;

  return textfinal.codeUnits;
}