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, _typeInfoPoly);
  bits.appendBits(bchCode, 10);

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

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