makeTypeInfoBits static method

void makeTypeInfoBits(
  1. ErrorCorrectionLevel ecLevel,
  2. int maskPattern,
  3. BitArray bits
)

Implementation

static void makeTypeInfoBits(
  ErrorCorrectionLevel ecLevel,
  int maskPattern,
  BitArray bits,
) {
  if (!QRCode.isValidMaskPattern(maskPattern)) {
    throw WriterException('Invalid mask pattern');
  }
  final typeInfo = (ecLevel.index << 3) | maskPattern;
  bits.appendBits(typeInfo, 5);

  final bchCode = calculateBCHCode(typeInfo, _TYPE_INFO_POLY);
  bits.appendBits(bchCode, 10);

  final maskBits = BitArray();
  maskBits.appendBits(_TYPE_INFO_MASK_PATTERN, 15);
  bits.xor(maskBits);

  if (bits.size != 15) {
    // Just in case.
    throw WriterException('should not happen but we got: ${bits.size}');
  }
}