ibanChecksum function

String ibanChecksum(
  1. String address
)

Implementation

String ibanChecksum(String address) {
  address = address.toUpperCase();
  address = "${address.substring(4)}${address.substring(0, 2)}00";
  String expanded = address.split('').map((c) => ibanLookup[c]).join('');

  while (expanded.length >= safeDigits) {
    String block = expanded.substring(0, safeDigits);
    expanded =
        (int.parse(block) % 97).toString() + expanded.substring(block.length);
  }

  String checksum = (98 - (int.parse(expanded) % 97)).toString();
  while (checksum.length < 2) {
    checksum = "0$checksum";
  }

  return checksum;
}