luhnAppend static method

String luhnAppend(
  1. String input
)

Appends a Luhn checksum digit (Z) to the input string.

The input parameter is the string to which the checksum is appended. Returns the input string with the Luhn checksum digit appended.

Implementation

static String luhnAppend(String input) {
  final digits =
      input.codeUnits.map((char) => char - '0'.codeUnitAt(0)).toList();
  digits.add(luhnChecksum(digits));

  return utf8
      .decode(digits.map((digit) => digit + '0'.codeUnitAt(0)).toList());
}