Skip to content
On this page

OTP

A segmented one-time-password input with autofill support.

OTP in FluttyUIOTP in FluttyUI dark theme

Import

import 'package:flutter/widgets.dart';
import 'package:fluttyui/fluttyui.dart' as ui;

API Reference

The declarations below match the current FluttyUI source. Types are shown without the optional ui. import prefix.

OTP

const OTP({
  super.key,
  this.size,
  this.length = 6,
  this.controller,
  this.value,
  this.autofillHints = const [AutofillHints.oneTimeCode],
  this.autofocus = false,
  this.onChanged,
  this.onCompleted,
  this.enabled = true,
  this.obscureText = false,
  this.boxSize,
  this.boxWidth,
  this.boxHeight,
  this.spacing,
  this.borderRadius,
  this.backgroundColor,
  this.borderColor,
  this.focusedBorderColor,
  this.textColor,
  this.fontSize,
  this.separator = '-',
  this.separatorAfter = 3,
});
ParameterTypeRequiredDefault
keyKey?Nonull
sizeComponentSize?Nonull
lengthintNo6
controllerTextEditingController?Nonull
valueString?Nonull
autofillHintsIterable<String>?Noconst [AutofillHints.oneTimeCode]
autofocusboolNofalse
onChangedValueChanged<String>?Nonull
onCompletedValueChanged<String>?Nonull
enabledboolNotrue
obscureTextboolNofalse
boxSizedouble?Nonull
boxWidthdouble?Nonull
boxHeightdouble?Nonull
spacingdouble?Nonull
borderRadiusdouble?Nonull
backgroundColorColor?Nonull
borderColorColor?Nonull
focusedBorderColorColor?Nonull
textColorColor?Nonull
fontSizedouble?Nonull
separatorString?No'-'
separatorAfterintNo3

Application Setup

Place components under FluttyApp to provide theme, navigation, localization, and overlay defaults. Use theme tokens for shared appearance settings.

Source

lib/src/widgets/forms/input_otp/otp.dart

This reference is generated from the OTP declaration in the FluttyUI core checkout. The component catalog lists the other available building blocks.

DartFlutter

Get started with FluttyUI