obterCep static method

String obterCep(
  1. String cep, {
  2. bool ponto = true,
})

Retorna o CNPJ informado, utilizando a máscara: XX.YYY-ZZZ

Para remover o ., informe ponto=false.

Implementation

static String obterCep(String cep, {bool ponto = true}) {
  assert(
      cep.length == 8, 'CEP com tamanho inválido. Deve conter 8 caracteres');

  return ponto
      ? '${cep.substring(0, 2)}.${cep.substring(2, 5)}-${cep.substring(5, 8)}'
      : '${cep.substring(0, 2)}${cep.substring(2, 5)}-${cep.substring(5, 8)}';
}