InputOTPChild.character constructor
InputOTPChild.character({})
Implementation
factory InputOTPChild.character({
bool allowLowercaseAlphabet = false,
bool allowUppercaseAlphabet = false,
bool allowDigit = false,
bool obscured = false,
bool onlyUppercaseAlphabet = false,
bool onlyLowercaseAlphabet = false,
bool readOnly = false,
TextInputType? keyboardType,
}) {
assert(!(onlyUppercaseAlphabet && onlyLowercaseAlphabet),
'onlyUppercaseAlphabet and onlyLowercaseAlphabet cannot be true at the same time');
keyboardType ??= allowDigit &&
!allowLowercaseAlphabet &&
!allowUppercaseAlphabet &&
!onlyUppercaseAlphabet &&
!onlyLowercaseAlphabet
? TextInputType.number
: TextInputType.text;
return CharacterInputOTPChild(
predicate: (codepoint) {
if (allowLowercaseAlphabet &&
CharacterInputOTPChild.isAlphabetLower(codepoint)) {
return true;
}
if (allowUppercaseAlphabet &&
CharacterInputOTPChild.isAlphabetUpper(codepoint)) {
return true;
}
if (allowDigit && CharacterInputOTPChild.isDigit(codepoint)) {
return true;
}
return false;
},
transform: (codepoint) {
if (onlyUppercaseAlphabet) {
return CharacterInputOTPChild.lowerToUpper(codepoint);
}
if (onlyLowercaseAlphabet) {
return CharacterInputOTPChild.upperToLower(codepoint);
}
return codepoint;
},
keyboardType: keyboardType,
obscured: obscured,
readOnly: readOnly,
);
}