otpField method
Widget
otpField({
- required TextEditingController controller,
- required String hint,
- String? label,
- FormFieldValidator<
String> ? validator, - ValueChanged<
String> ? onSubmitted, - int? maxLength,
Single-field OTP input (kept for hosts that build their own layout).
Implementation
Widget otpField({
required TextEditingController controller,
required String hint,
String? label,
FormFieldValidator<String>? validator,
ValueChanged<String>? onSubmitted,
int? maxLength,
}) {
final field = TextFormField(
controller: controller,
keyboardType: TextInputType.number,
textAlign: TextAlign.center,
style: otpTextStyle,
maxLength: maxLength,
obscureText: theme.otpHidden,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration:
(theme.inputUnderline
? underlineInputDecoration(hint: hint, label: label)
: otpInputDecoration(hint: hint, label: label))
.copyWith(counterText: ''),
validator: validator,
onFieldSubmitted: onSubmitted,
autofillHints: const [AutofillHints.oneTimeCode],
);
return theme.inputUnderline ? field : decorateInput(field);
}