obterCep method

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

Implementation

static String obterCep(String cep, {bool ponto = true}) {
  assert(
      cep.length == 8, 'CEP com tamanho inválido. Deve conter 8 caracteres');
  if (ponto) {
    return cep.substring(0, 2) +
        '.' +
        cep.substring(2, 5) +
        '-' +
        cep.substring(5, 8);
  }
  return cep.substring(0, 2) +
      cep.substring(2, 5) +
      '-' +
      cep.substring(5, 8);
}