UOtpField class
One-time-code boxes with paste, SMS autofill, obscuring and error state. UOtpField(length: 6, onCompleted: verify)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- UOtpField
- Available extensions
Constructors
-
UOtpField({Key? key, TextEditingController? controller, FocusNode? focusNode, int length = 6, UOtpKeyboardMode keyboardMode = UOtpKeyboardMode.system, ValueChanged<
String> ? onChanged, ValueChanged<String> ? onCompleted, ValueChanged<String> ? onSubmitted, String? validator(String?)?, dynamic onSaved(String? value)?, bool autoFocus = false, bool enabled = true, bool readOnly = false, bool obscureText = false, String obscuringCharacter = "•", bool autoDismissKeyboard = true, bool hapticFeedback = true, bool enableSmsAutoFill = true, bool showCursor = true, bool expand = true, double fieldWidth = 48, double fieldHeight = 60, double spacing = 8, double borderRadius = 8, double borderWidth = 1, TextStyle? textStyle, Color? fillColor, Color? focusedFillColor, Color? cursorColor, Color? activeColor, Color? borderColor, Color? errorColor, Color? textColor, MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center, Duration animationDuration = const Duration(milliseconds: 150), TextInputType keyboardType = TextInputType.number, List<TextInputFormatter> ? inputFormatters, Widget separatorBuilder(BuildContext context, int index)?, Widget cellBuilder(BuildContext context, int index, String character, UOtpCellState state)?, Color? filledBorderColor, List<BoxShadow> ? activeBoxShadow, String characterFormatter(String character)?}) -
const
Properties
-
activeBoxShadow
→ List<
BoxShadow> ? -
Shadow of the focused box.
final
- activeColor → Color?
-
Border of the focused box.
final
- animationDuration → Duration
-
Length of the animation.
final
- autoDismissKeyboard → bool
-
Closes the keyboard when complete.
final
- autoFocus → bool
-
Focuses the first box on start.
final
- borderColor → Color?
-
Border color.
final
- borderRadius → double
-
Corner radius.
final
- borderWidth → double
-
Border thickness.
final
- cellBuilder → Widget Function(BuildContext context, int index, String character, UOtpCellState state)?
-
Your own box widget.
final
- characterFormatter → String Function(String character)?
-
Formats each character (e.g. Persian digits).
final
- controller → TextEditingController?
-
Controller to read or change it from code.
final
- cursorColor → Color?
-
Cursor color.
final
- enabled → bool
-
False disables interaction and greys it out.
final
- enableSmsAutoFill → bool
-
Offers the code from SMS (iOS/Android autofill).
final
- errorColor → Color?
-
Border color on error.
final
- expand → bool
-
Stretches boxes to the full width.
final
- fieldHeight → double
-
Box height.
final
- fieldWidth → double
-
Box width.
final
- fillColor → Color?
-
Fill color.
final
- filledBorderColor → Color?
-
Border of filled boxes.
final
- focusedFillColor → Color?
-
Fill of the focused box.
final
- focusNode → FocusNode?
-
Focus node to control keyboard focus.
final
- hapticFeedback → bool
-
Vibrates lightly on interaction (mobile).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputFormatters
→ List<
TextInputFormatter> ? -
Input formatters.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardMode → UOtpKeyboardMode
-
System keyboard or built-in pad.
final
- keyboardType → TextInputType
-
Keyboard type (numbers by default).
final
- length → int
-
Number of digits.
final
- mainAxisAlignment → MainAxisAlignment
-
How children are placed along the main axis.
final
- obscureText → bool
-
Hides the digits.
final
- obscuringCharacter → String
-
Character shown instead of digits.
final
-
onChanged
→ ValueChanged<
String> ? -
Called with the new value when the user changes it.
final
-
onCompleted
→ ValueChanged<
String> ? -
Called when the input is complete.
final
- onSaved → dynamic Function(String? value)?
-
Form save callback.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called when the keyboard's done is pressed.
final
- readOnly → bool
-
Shows the value without allowing edits.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- separatorBuilder → Widget Function(BuildContext context, int index)?
-
Widget between boxes (e.g. a dash after 3).
final
- showCursor → bool
-
Shows a blinking cursor.
final
- spacing → double
-
Gap between items.
final
- textColor → Color?
-
Text color.
final
- textStyle → TextStyle?
-
Text style.
final
- validator → String? Function(String?)?
-
Form validator; return an error text or null (see UValidators).
final
Methods
-
alignAtBottomCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the bottom center. -
alignAtBottomLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the bottom left. -
alignAtBottomRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the bottom right. -
alignAtCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Centered. -
alignAtCenterLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the center left. -
alignAtCenterRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the center right. -
alignAtLERP(
Alignment a, Alignment b, double t, {Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned betweenaandbatt(0 = a, 1 = b). -
alignAtTopCenter(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the top center. -
alignAtTopLeft(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the top left. -
alignAtTopRight(
{Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned to the top right. -
alignXY(
double x, double y, {Key? key, double? heightFactor, double? widthFactor}) → Align -
Available on Widget, provided by the WidgetsExtension extension
Aligned at x, y from -1 to 1.child.alignXY(0, -0.5) -
card(
{Color? backgroundColor, double? elevation, EdgeInsetsGeometry? margin}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Material Card around it.child.card(elevation: 2) -
center(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Centered in the available space.child.center() -
chip(
{required Color backgroundColor, double? width, double? height, Alignment? alignment, double borderWidth = 1, double radius = 12, Color borderColor = Colors.transparent, EdgeInsets padding = const EdgeInsets.symmetric(horizontal: 8, vertical: 6), EdgeInsetsGeometry? margin, BoxConstraints? constraints}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Pill-shaped colored box, e.g. for tags.Text("New").chip(backgroundColor: Colors.green.shade100) -
clipCircle(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Clips to a circle.avatar.clipCircle() -
clipRadius(
double radius) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Rounds the corners by clipping.image.clipRadius(12) -
container(
{double? width, double? height, Alignment? alignment, Color? backgroundColor, double borderWidth = 1, double radius = 1, Color borderColor = Colors.transparent, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, BoxConstraints? constraints}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Box with background, border and rounded corners.child.container(backgroundColor: Colors.white, radius: 12) -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< UOtpField> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
disabled(
bool disabled, {double opacity = 0.5}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Greys out and blocks taps whendisabled.form.disabled(isSaving) -
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Takes the remaining space in a Row/Column.child.expanded() -
fadeSlideIn(
{int milliseconds = 1000, double offset = 24}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Fades and slides up once when first shown.card.fadeSlideIn() -
fit(
{Alignment alignment = Alignment.center}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Shrinks to fit the space (never grows).Text(long).fit() -
flexible(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Can shrink in a Row/Column but does not have to fill.child.flexible() -
form(
GlobalKey< FormState> key) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Wraps in a Form withkey.column.form(formKey) -
hero(
Object tag) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Hero animation between pages with the sametag.image.hero("product-$id") -
ltr(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Forces left-to-right (numbers, phone numbers, code).Text(phone).ltr() -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onDoubleTap(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Double tap.image.onDoubleTap(like) -
onLongPress(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Long press.child.onLongPress(showOptions) -
onPress(
VoidCallback onTap, {double pressedScale = 0.9, Duration duration = const Duration(milliseconds: 120)}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Tap with a press-down shrink animation.card.onPress(open) -
onTap(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Tap without ripple.child.onTap(open) -
onTapInk(
GestureTapCallback? onPressed) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Tap with a Material ripple (needs a Material ancestor).tile.onTapInk(open) -
opacity(
double opacity) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Makes it see-through (0 = invisible, 1 = solid).child.opacity(0.5) -
pAll(
double padding) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Same padding on every side.child.pAll(16) -
pLTRB(
double left, double top, double right, double bottom) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Padding left, top, right, bottom.child.pLTRB(8, 4, 8, 4) -
pOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Padding on chosen sides.child.pOnly(top: 8) -
position(
{double? left, double? top, double? right, double? bottom, double? width, double? height}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Positioned inside a Stack.badge.position(top: 0, right: 0) -
pSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Horizontal and/or vertical padding.child.pSymmetric(horizontal: 16) -
rotate(
double scale) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Rotates byscaleradians.arrow.rotate(pi / 2) -
rtl(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Forces right-to-left.child.rtl() -
safeArea(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Keeps it out of the notch and system bars.body.safeArea() -
scale(
double scale) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Scales the paint (layout size unchanged).icon.scale(1.5) -
scrollable(
{Axis scrollDirection = Axis.vertical}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Makes it scroll when it does not fit.column.scrollable() -
showMenus(
List< PopupMenuEntry< items) → Widgetint> > -
Available on Widget, provided by the WidgetsExtension extension
Shows a popup menu where the user taps; items return their int value.child.showMenus([PopupMenuItem(value: 1, child: Text("Edit"))]) -
sized(
{double? width, double? height}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Fixed width and/or height.logo.sized(width: 48, height: 48) -
skeleton(
bool loading) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Draws a shimmering loading placeholder in its shape whileloading.Text("Name").skeleton(isLoading) -
sliver(
) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Lets a normal widget sit inside a CustomScrollView.header.sliver() -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
tooltip(
String message) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Showsmessageon long press / mouse hover.icon.tooltip("Delete") -
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
translate(
Offset offset) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Moves the paint byoffset(layout unchanged).child.translate(const Offset(0, -4)) -
visible(
bool visible, {bool maintainSize = false}) → Widget -
Available on Widget, provided by the WidgetsExtension extension
Shows it only whenvisible; withmaintainSizeit keeps its space.saveButton.visible(isDirty)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited