addItemTexts method

void addItemTexts(
  1. List<String> texts, {
  2. ReceiptTextSizeType size = ReceiptTextSizeType.extraLarge,
})

Implementation

void addItemTexts(List<String> texts, { ReceiptTextSizeType size = ReceiptTextSizeType.extraLarge}) {

  String htmlContent= '';

  switch(numberColumn){
    case 1:
      for(int i = 0; i < texts.length; i++){
        htmlContent += '''
        <div class="$_row">
          ${getItem(texts[i], ReceiptColumn.one, size)}
        </div>
        ''';
      }
      break;
    case 2:
      final int mod = texts.length%2==0?0:1;

      for(int i = 0; i < texts.length; i=i+2){

        final String rowClass = i+2 == texts.length+mod ? _rowLast: _row;

        htmlContent += '''
        <div class="$rowClass">
          ${getItem(texts[i], ReceiptColumn.two, size, alignment: ReceiptAlignment.left )}
        ''';

        if(i+1 < texts.length){
          htmlContent += '''
                ${getItem(texts[i+1], ReceiptColumn.two, size, isMargin: true, alignment: ReceiptAlignment.right)}
              </div>
              ''';
        } else{
          htmlContent += '''</div>''';
        }
      }
      break;
    case 3 :

      for (int i = 0; i < texts.length; i++) {
        if(i % 3 == 0)
          htmlContent += (i > 0) ? '''</div> <div class="$_row">''' : ''' <div class="$_row">''';
        htmlContent += getItem(texts[i], ReceiptColumn.three, size);
      }
      htmlContent+='''</div>''';
      break;
  }
  _data += htmlContent;
}