getCharPositon function

int getCharPositon(
  1. String character
)

This method returns the position of a given character as an integer.

Implementation

int getCharPositon(String character) {
  int result = 0;
  String labString = character.toLowerCase();
  String alphabet = 'abcdefghijklmnopqrstuvw';
  List<String> alphabetList = alphabet.split('');
  for (int i = 0; i < alphabetList.length; i++) {
    if (alphabetList[i] == labString) {
      result = i + 1;
      break;
    } else {
      // Do nothing.
    }
  }
  return result;
}