makeText method

  1. @override
Iterable<BarcodeElement> makeText(
  1. String data,
  2. double width,
  3. double height,
  4. double fontHeight,
  5. double textPadding,
  6. double lineWidth,
)
override

Stream the text operations required to draw the barcode texts. This is automatically called by make

Implementation

@override
Iterable<BarcodeElement> makeText(
  String data,
  double width,
  double height,
  double fontHeight,
  double textPadding,
  double lineWidth,
) sync* {
  final text = checkLength(data, maxLength);
  final w = lineWidth * 7;
  final left = marginLeft(true, width, height, fontHeight, textPadding);
  final right = marginRight(true, width, height, fontHeight, textPadding);

  yield BarcodeText(
    left: 0,
    top: height - fontHeight,
    width: left - lineWidth,
    height: fontHeight,
    text: text[0],
    align: BarcodeTextAlign.right,
  );

  var offset = left + lineWidth * 10;

  for (var i = 1; i < text.length - 1; i++) {
    yield BarcodeText(
      left: offset,
      top: height - fontHeight,
      width: w,
      height: fontHeight,
      text: text[i],
      align: BarcodeTextAlign.center,
    );

    offset += w;
    if (i == 5) {
      offset += lineWidth * 5;
    }
  }

  yield BarcodeText(
    left: width - right + lineWidth,
    top: height - fontHeight,
    width: right - lineWidth,
    height: fontHeight,
    text: text[text.length - 1],
    align: BarcodeTextAlign.left,
  );
}