format static method
Implementation
static String? format(String? cpf) {
if (cpf == null) return null;
// Obter somente os números do CPF
var numeros = cpf.replaceAll(RegExp(r'[^0-9]'), '');
// Testar se o CPF possui 11 dígitos
if (numeros.length != 11) return cpf;
// Retornar CPF formatado
return '${numeros.substring(0, 3)}.${numeros.substring(3, 6)}.${numeros.substring(6, 9)}-${numeros.substring(9)}';
}