willFit static method
@return true if the number of input bits will fit in a code with the specified version and error correction level.
Implementation
static bool willFit(
int numInputBits,
Version version,
ErrorCorrectionLevel ecLevel,
) {
// In the following comments, we use numbers of Version 7-H.
// numBytes = 196
final numBytes = version.totalCodewords;
// getNumECBytes = 130
final ecBlocks = version.getECBlocksForLevel(ecLevel);
final numEcBytes = ecBlocks.totalECCodewords;
// getNumDataBytes = 196 - 130 = 66
final numDataBytes = numBytes - numEcBytes;
final totalInputBytes = (numInputBits + 7) ~/ 8;
return numDataBytes >= totalInputBytes;
}