formatarTextoPrimeirasLetrasMaiusculas static method

String formatarTextoPrimeirasLetrasMaiusculas(
  1. String txt
)

Implementation

static String formatarTextoPrimeirasLetrasMaiusculas(String txt) {
  try {
    List texto = txt.split(' ');
    txt = '';
    int i = 0;
    for (var value in texto) {
      if (i > 0 && (value == 'DA' || value == 'DE' || value == 'DI' || value == 'DO' || value == 'DU' || value == 'A' || value == 'E' || value == 'I' || value == 'O' || value == 'U' || value == 'DOS' || value == 'DAS'))
        txt = '$txt ${value.toString().toLowerCase()}';
      else
        txt = '$txt ${value.toString().substring(0, 1).toUpperCase()}${value.toString().substring(1, value.toString().length).toLowerCase()}';
      i++;
    }
    return txt.substring(1, txt.length).trim();
  } catch (e) {
    //--
  }
  return txt;
}