A flutter package for the OTP Field widget.

Overview

OTP Text Field

A flutter package to create a OTP Text Field widget in your application.


Stay tuned for the latest updates:


Pub Twitter

๐Ÿ“ฑ Screenshots


โš™๏ธ Installation

Import the following package in your dart file

import 'package:otp_text_field/otp_field.dart';
import 'package:otp_text_field/style.dart';

๐Ÿ‘จโ€๐Ÿ’ป Usage

Use the OTP Text Field Widget

OTPTextField(
  length: 5,
  width: MediaQuery.of(context).size.width,
  fieldWidth: 80,
  style: TextStyle(
    fontSize: 17
  ),
  textFieldAlignment: MainAxisAlignment.spaceAround,
  fieldStyle: FieldStyle.underline,
  onCompleted: (pin) {
    print("Completed: " + pin);
  },
),

For more detail on usage, check out the example provided.

๐Ÿ™๐Ÿปโ€โ™‚๏ธ Author

๐Ÿ“„ License

OTP Text Field is released under the MIT license. See LICENSE for details.

Comments
  • Null check operator used on a null value

    Null check operator used on a null value

    When onChanged is not passed then this error is thrown .After passing onChanged it works fine.

    Null check operator used on a null value

    This is the stack

    When the exception was thrown, this was the stack: #0 _OTPTextFieldState.buildTextField. (package:otp_text_field/otp_field.dart:156:27) #1 EditableTextState._formatAndSetValue (package:flutter/src/widgets/editable_text.dart:2276:27) #2 EditableTextState.textEditingValue= (package:flutter/src/widgets/editable_text.dart:2474:5) #3 RenderEditable._handleDelete (package:flutter/src/rendering/editable.dart:877:27) #4 RenderEditable._handleKeyEvent (package:flutter/src/rendering/editable.dart:550:7)

    opened by abhimanyu95 9
  • OTPTextField' isn't a function.\nTry correcting the name to match an existing function, or define a method or function named 'OTPTextField

    OTPTextField' isn't a function.\nTry correcting the name to match an existing function, or define a method or function named 'OTPTextField

    Throwing multiple issues.

    Error One: [{ "resource": "/d:/mobile_apps_source/ppnnews/lib/components/OTPDialog.dart", "owner": "generated_diagnostic_collection_name#0", "code": { "value": "ambiguous_import", "target": { "$mid": 1, "external": "https://dart.dev/diagnostics/ambiguous_import", "path": "/diagnostics/ambiguous_import", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "The name 'OTPTextField' is defined in the libraries 'package:nb_utils/src/widgets/otp_text_field.dart (via package:nb_utils/nb_utils.dart)' and 'package:otp_text_field/otp_field.dart'.\nTry using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.", "source": "dart", "startLineNumber": 188, "startColumn": 17, "endLineNumber": 188, "endColumn": 29 }]

    Error Two: [{ "resource": "/d:/mobile_apps_source/ppnnews/lib/components/OTPDialog.dart", "owner": "generated_diagnostic_collection_name#0", "code": { "value": "invocation_of_non_function", "target": { "$mid": 1, "external": "https://dart.dev/diagnostics/invocation_of_non_function", "path": "/diagnostics/invocation_of_non_function", "scheme": "https", "authority": "dart.dev" } }, "severity": 8, "message": "'OTPTextField' isn't a function.\nTry correcting the name to match an existing function, or define a method or function named 'OTPTextField'.", "source": "dart", "startLineNumber": 188, "startColumn": 17, "endLineNumber": 188, "endColumn": 29 }]

    Please help

    Screenshot (53) Screenshot (54) Screenshot (52)

    opened by 5M06 5
  • Add textCapitalization

    Add textCapitalization

    To enable the following feature:

    https://stackoverflow.com/questions/49238908/flutter-textfield-value-always-uppercase-debounce

    It's not possible to always use upper case characters. ๐ŸŽ‰

    opened by stefanschaller 4
  • Allow entry of 6 digit OTP code.

    Allow entry of 6 digit OTP code.

    I am working with a backend that sends a 6-digit OTP code. However, I noticed that this library only allows the entry of codes of length, not more than 5.

    opened by odaga 2
  • handling Custom keyboard

    handling Custom keyboard

    I want to use this with my custom Keyboard but didn't find something like controller as available in TextField widget to use here. How can I implement that here?

    opened by Pranav108 2
  • Called on null issue after flutter 2.0 upgrade

    Called on null issue after flutter 2.0 upgrade

    while typing text or numbers in OTP text field, called on null issue was arising after my project upgraded into flutter 2.0.1. I think it was related to null safety. I hope this issue has been fixed as soon as possible. Screenshot (18)

    opened by selvas1998 2
  • Deleting problem before finishing

    Deleting problem before finishing

    Several libraries do not allow deleting and going back to the previous TextInput, this solves it very well.

    Example of the problem: In an OTPTextField with length: 4, typing the 4 digits and then deleting works correctly. But trying to delete without reaching the fourth TextField it just doesn't go back to the previous TextField.

    Tested on Android.

    opened by federicodesia 2
  • How to trigger OTPTextField to use the errorBorderColor / disabledBorderColor?

    How to trigger OTPTextField to use the errorBorderColor / disabledBorderColor?

    how to trigger OTPTextField to use the errorBorderColor / disabledBorderColor?

    Originally posted by @aulia-rosyida in https://github.com/iamvivekkaushik/OTPTextField/issues/2#issuecomment-1034918465

    opened by timkanurmamatov 1
  • InputFormatter Digits Only

    InputFormatter Digits Only

    I hope inputFormatters property in OTPTextField will be added, so that we can restrict what type of characters that user can input in the textfield .

    ex. inputFormatters: [WhitelistingTextInputFormatter.digitsOnly],

    opened by cenezoic123 1
  • FIX: back press on empty box fix

    FIX: back press on empty box fix

    The idea is to add whitespace in each text field when changing focus and remove it when entering a new value, So when back pressed the onChnage call back will work

    • Closes #35
    • Closes #22
    • Closes #24
    opened by fayis672 0
  • Why doesn't onCompleted state change when the OTPTextField is no longer

    Why doesn't onCompleted state change when the OTPTextField is no longer "Completed"?

    While using the package I noticed that when the OTPTextField is completely filled onCompleted is triggered, why doesn't it trigger when the OTPTextField is no longer filled?

    opened by maykhid 0
  • TypeErrorImpl was thrown while calling onChanged: Unexpected null value

    TypeErrorImpl was thrown while calling onChanged: Unexpected null value

    I have opened a question on stackoverflow when i used onChanged method if someone is getting this error can check the answers https://stackoverflow.com/questions/73508987/typeerrorimpl-was-thrown-while-calling-onchanged-unexpected-null-value-flutte

    opened by debjeetproso 0
  • Backspace does not work on empty field

    Backspace does not work on empty field

    Hi, first of all great feature that you have developed. ๐Ÿ‘

    I am using latest version on android and if I press backspace when an otpbox is empty it does not go to the previous otp box.

    Hope you get it fixed, it would be great to have.

    ๐Ÿ™ Thanks

    opened by khayargoli 0
Owner
Vivek Kaushik
Mobile App Developer.
Vivek Kaushik
A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

Carlos Eugenio Torres 73 Sep 7, 2022
A simple Flutter widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

nil A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance. Why? Sometimes, according to a condit

Romain Rastel 127 Dec 22, 2022
A flutter carousel widget, support infinite scroll, and custom child widget.

carousel_slider A carousel slider widget. Features Infinite scroll Custom child widgets Auto play Supported platforms Flutter Android Flutter iOS Flut

Bart T 1 Nov 25, 2021
A Flutter Widget to make interactive timeline widget.

Bubble Timeline Package A Flutter Widget to make interactive timeline widget. This widget can be used to make Event Timelines, or Timelines for certai

Vansh Goel 12 Sep 22, 2022
๐Ÿ“ธ Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget.

?? Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Blue Fire 1.7k Jan 7, 2023
A widget lib that the widget in this lib can react to flutter ScrollController's offset

Language: English | ไธญๆ–‡็ฎ€ไฝ“ linked_scroll_widgets A lib full of widgets that can react to the scrollController's offset change,to custom your UI effect.

WenJingRui 8 Oct 16, 2022
Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget

lite_rolling_switch Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget https://github.com/pedromas

Eduardo Muรฑoz 48 Dec 1, 2022
Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

DISCONTINUED Checkout ArsDialog ars_progress_dialog Customizable progress dialog for Flutter applications with smooth animation for background dim col

Arsam 8 Apr 15, 2022
A Flutter widget that will give a Glitch Animation Effect to it's child widget.

GlitchEffect A Flutter widget that will give a Glitch Animation Effect to it's child widget. Installation Add the latest version of package to your pu

Sameer Singh 6 Nov 25, 2022
Widget, that can make any static located widget hidable

Installing See the official installing guidline from hidable/install Usage & Overview To start using Hidable widget, we have to create a ScrollControl

Anon 18 Dec 16, 2022
A widget that allow user resize the widget with drag

Flutter-Resizable-Widget A widget that allow user resize the widget with drag Note: this widget uses Getx Example bandicam.2021-11-11.12-34-41-056.mp4

MohammadAminZamani.afshar 22 Dec 13, 2022
Flutter Package: When your desired layout or animation is too complex for Columns and Rows, this widget lets you position/size/rotate/transform its child in complex ways.

align_positioned Widgets in this package: AlignPositioned AnimatedAlignPositioned AnimChain Why are these widgets an indispensable tool? When your des

Marcelo Glasberg 69 Dec 12, 2022
The flutter_otp_text_field package for flutter is a TextField widget that allows you to display different style pin.

flutter_otp_text_field flutter_otp_text_field The flutter_otp_text_field package for flutter is a TextField widget that allows you to display differen

David-Legend 30 Nov 8, 2022
An awesome Flutter package with widget extension.

jr_extension An awesome Flutter package with widget extension. Why do I want to create this lib? In SwiftUI framework created

WenJingRui 2 Sep 28, 2022
A flutter package to control rebuilds of a widget based on updates of a Listenable

A flutter package to control rebuilds of a widget based on updates of a Listenable. What is Grab? Grab is similar to ValueListenablebuiler or Animated

Kabo 5 Dec 3, 2022
Flutter package which helps you to implement Ticket Widget in your app.

โœจ Ticket Widget Flutter package which helps you to implement Ticket Widget in your app. The source code is 100% Dart, and it is an updated null safe v

Mujahid 7 Dec 30, 2022
Flutter Carousel Pro - A Flutter Carousel widget

Carousel Extended A Flutter Carousel widget. Usage As simple as using any flutter Widget. Based on Carousel Pro but extended to be able to navigate be

omid habibi 3 Dec 7, 2020
๐ŸŸฅ A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

?? A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

Andrei Lesnitsky 32 Oct 8, 2022
React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.

English | Portuguรชs Flutter Hooks A Flutter implementation of React hooks: https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 Ho

Remi Rousselet 2.6k Dec 29, 2022