kisIdCardExact method
是否匹配身份证号码-精准匹配
Implementation
bool kisIdCardExact() {
var file = this;
if (file != null && file.length == 18) {
List<int> factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
List<String> suffix = [
'1',
'0',
'X',
'9',
'8',
'7',
'6',
'5',
'4',
'3',
'2'
];
if (cityMap.isEmpty) {
List<String> list = idCardProvinceList;
List<MapEntry<String, String>> mapEntryList = [];
for (int i = 0, length = list.length; i < length; i++) {
List<String> tokens = list[i].trim().split('=');
MapEntry<String, String> mapEntry = MapEntry(tokens[0], tokens[1]);
mapEntryList.add(mapEntry);
}
cityMap.addEntries(mapEntryList);
}
if (cityMap[file.substring(0, 2)] != null) {
int weightSum = 0;
for (int i = 0; i < 17; ++i) {
weightSum += (file.codeUnitAt(i) - '0'.codeUnitAt(0)) * factor[i];
}
int idCardMod = weightSum % 11;
String idCardLast = String.fromCharCode(file.codeUnitAt(17));
return idCardLast == suffix[idCardMod];
}
}
return false;
}