makeBytes method

  1. @override
Iterable<BarcodeElement> makeBytes(
  1. Uint8List data, {
  2. required double width,
  3. required double height,
  4. bool drawText = false,
  5. double? fontHeight,
  6. double? textPadding,
})
override

Implementation

@override
Iterable<BarcodeElement> makeBytes(
  Uint8List data, {
  required double width,
  required double height,
  bool drawText = false,
  double? fontHeight,
  double? textPadding,
}) sync* {
  assert(width > 0);
  assert(height > 0);
  assert(!drawText || fontHeight != null);
  fontHeight ??= 0;
  textPadding ??= Barcode1D.defaultTextPadding;

  yield* super.makeBytes(
    data,
    width: width,
    height: height,
    drawText: drawText,
    fontHeight: fontHeight,
    textPadding: textPadding,
  );

  if (drawBorder) {
    final double bw = _getBorderWidth(width);
    final num hp = drawText ? fontHeight + textPadding : 0;

    yield BarcodeBar(left: 0, top: 0, width: width, height: bw, black: true);
    yield BarcodeBar(left: 0, top: height - hp - bw, width: width, height: bw, black: true);
    yield BarcodeBar(left: 0, top: bw, width: bw, height: height - hp - bw * 2, black: true);
    yield BarcodeBar(left: width - bw, top: bw, width: bw, height: height - hp - bw * 2, black: true);
  }
}