extractCpfFromBlock static method
Extracts the CPF from a natural-person positional block.
A value that is already an isolated CPF is accepted as well.
Implementation
static String? extractCpfFromBlock(String? value) {
final digits = _digitsOnly(value);
if (digits == null) return null;
if (digits.length == 11) {
return isValidCpf(digits) ? digits : null;
}
if (digits.length >= _cpfEnd) {
final cpf = digits.substring(_cpfStart, _cpfEnd);
return isValidCpf(cpf) ? cpf : null;
}
return null;
}