getSpecialCharsKeyRows method

List<List<SecureKeyboardKey>> getSpecialCharsKeyRows()

Returns a list of special characters key rows.

Implementation

List<List<SecureKeyboardKey>> getSpecialCharsKeyRows() {
  final random = Random();
  int randomIndex;
  int emptyLength;

  return List.generate(_specialCharsKeyRows.length, (int rowNum) {
    List<SecureKeyboardKey> rowKeys = [];

    switch (rowNum) {
      case 3:
        rowKeys.add(_shiftActionKey());
        rowKeys.addAll(_buildStringKeyRow(_specialCharsKeyRows, rowNum));
        emptyLength = _specialCharsKeyRows[rowNum].length;
        randomIndex = random.nextInt(emptyLength) + 1;
        rowKeys.insert(randomIndex, _blankActionKey());
        rowKeys.add(_backspaceActionKey());
        break;
      case 4:
        rowKeys.add(_specialCharsActionKey());
        rowKeys.add(_clearActionKey());
        rowKeys.add(_doneActionKey());
        break;
      default:
        rowKeys = _buildStringKeyRow(_specialCharsKeyRows, rowNum);
        emptyLength = _specialCharsKeyRowMaxLength -
            _specialCharsKeyRows[rowNum].length;

        for (var i = 0; i < emptyLength; i++) {
          randomIndex = random.nextInt(_specialCharsKeyRowMaxLength);
          if (randomIndex == _specialCharsKeyRowMaxLength - 1) {
            rowKeys.add(_blankActionKey());
          } else {
            rowKeys.insert(randomIndex, _blankActionKey());
          }
        }
    }

    return rowKeys;
  });
}