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* {
  data = checkLength(data, maxLength);
  final w = lineWidth * 7;
  final left = marginLeft(true, width, height, fontHeight, textPadding);
  final right = marginRight(true, width, height, fontHeight, textPadding);
  var offset = left + lineWidth * 3;

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

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

  if (drawSpacers) {
    yield BarcodeText(
      left: 0,
      top: height - fontHeight,
      width: left - lineWidth,
      height: fontHeight,
      text: _startSpacer,
      align: BarcodeTextAlign.right,
    );
    yield BarcodeText(
      left: width - right + lineWidth,
      top: height - fontHeight,
      width: right - lineWidth,
      height: fontHeight,
      text: _finalSpacer,
      align: BarcodeTextAlign.left,
    );
  }
}