OTPInputType enum

Defines the type of characters allowed in OTP input fields.

This determines which characters the user can enter and what keyboard is shown. Input formatters are automatically applied based on this type.

Example usage:

OTPTextField(
  inputType: OTPInputType.text,
  textCapitalization: TextCapitalization.characters,
  controllers: controllers,
  focusNodes: focusNodes,
  textStyle: TextStyle(fontSize: 24),
)

See also:

Inheritance
Available extensions

Values

number → const OTPInputType

Only numeric digits (0-9) are allowed.

This is the default and most common type for OTP codes. Automatically shows the numeric keyboard on mobile devices.

Example:

OTPTextField(
  inputType: OTPInputType.number, // Default
)
// User can only enter: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Best for:

  • SMS OTP codes
  • Numeric PINs
  • Two-factor authentication codes
text → const OTPInputType

Only alphabetic characters (a-z, A-Z) are allowed.

Numbers and special characters are blocked. Useful for letter-based codes or when you want text-only input.

Example:

OTPTextField(
  inputType: OTPInputType.text,
  textCapitalization: TextCapitalization.characters,
)
// User can only enter: a-z, A-Z

Tip: Combine with TextCapitalization.characters to auto-uppercase.

Best for:

  • Letter-based verification codes
  • Custom authentication schemes
  • Game codes with letters only
any → const OTPInputType

Both numeric digits and alphabetic characters are allowed.

Accepts alphanumeric input (0-9, a-z, A-Z). Special characters are still blocked.

Example:

OTPTextField(
  inputType: OTPInputType.any,
  textCapitalization: TextCapitalization.characters,
)
// User can enter: 0-9, a-z, A-Z

Best for:

  • Mixed alphanumeric codes
  • Promotional codes
  • License keys

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

values → const List<OTPInputType>
A constant List of the values in this enum, in order of their declaration.