Flutter_Pinput treats a pin field as six themed states
Flutter package to create Pin code input text field with every pixel customization possibility 🎨 with beautiful animations, iOS autofill, Android autofill
At a glance
- What is it?
- Flutter_Pinput is a MIT licensed Dart package that renders a one time code entry field in Flutter, with a separate theme per interaction state, animation between states, form validation and SMS autofill. It is widely used and heavily customised; check pub.dev for the current package version and SDK requirements.
- Who is it for?
- Flutter_Pinput suits a Flutter team that needs a one time code field whose look is defined by the design system rather than by the platform default, and that wants the keyboard, cursor and obscuring behaviour under its own control. Check pub.dev for the current package version and SDK requirements, verify that the README matches the version you install, and read the migration notes when upgrading.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 7 days ago.
- What is it written in?
- Mainly Dart, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 17, 2026, and from our analysis. They are not legal advice.
Star history
- Tkko/Flutter_Pinput860 ★ · +1
| Repository | 2026-10-21 | 2026-11-17 |
|---|---|---|
| Tkko/Flutter_Pinput | 859 | 860 |
1 Stars in the last 27 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Six states, each with its own theme
The design idea at the centre of Flutter_Pinput is that a pin field is a small state machine, and each state gets its own visual treatment. The README names six of them: default, focused, submitted, following, disabled and error. You customize each one by passing the corresponding theme parameter, and the pin animates smoothly from one state to another automatically rather than snapping. That is the difference between this package and a row of text fields with a border. In a text field row, the focus indicator is drawn by the platform and the selection state is invisible, so a verification screen cannot visually distinguish the digit the user is about to change from the one they just entered. Here, the following state can be styled to look different from the focused state, which is what makes the field readable at a glance. The properties available on the theme are width, height, textStyle, margin, padding and constraints, with defaults of 56.0 for width and 60.0 for height.
The smallest useful usage is one widget
The default configuration is deliberately tiny, because the package assumes you will want to theme it later but does not force it. You construct the widget and give it a completion callback:
Widget buildPinPut() {
return Pinput(
onCompleted: (pin) => print(pin),
);
}The callback fires when the last digit is entered. The widget name in the README is Pinput, and the package on pub.dev is pinput, so the import name and the repository name differ, which matters if you are copying identifiers from an issue thread. Beyond that the feature list is broader than the widget itself: animated decoration switching, form validation, SMS autofill on both iOS and Android, a standard cursor, a custom cursor, cursor animation, copy from clipboard, readiness for a custom keyboard, the standard paste option, an obscuring character, an obscuring widget, haptic feedback and closing the keyboard after completion. Those are the knobs that separate a polished OTP screen from a rushed one.
Theming starts from one PinTheme and branches with copyWith
Customisation follows a copy and override pattern, and the README shows the full chain. You define a base theme first:
final defaultPinTheme = PinTheme(
width: 56,
height: 56,
textStyle: TextStyle(fontSize: 20, color: Color.fromRGBO(30, 60, 87, 1), fontWeight: FontWeight.w600),
decoration: BoxDecoration(
border: Border.all(color: Color.fromRGBO(234, 239, 243, 1)),
borderRadius: BorderRadius.circular(20),
),
);Then the other states derive from it, and the README offers two different copy helpers for two different jobs. copyDecorationWith replaces only the decoration, leaving other fields alone, which is what you want when the focused state differs only in its border colour and corner radius:
final focusedPinTheme = defaultPinTheme.copyDecorationWith(
border: Border.all(color: Color.fromRGBO(114, 178, 238, 1)),
borderRadius: BorderRadius.circular(8),
);
final submittedPinTheme = defaultPinTheme.copyWith(
decoration: defaultPinTheme.decoration.copyWith(
color: Color.fromRGBO(234, 239, 243, 1),
),
);copyWith is the general case, where you replace a field and provide the new decoration yourself. If you want all pins to look identical, the README notes that you simply do not pass the other theme parameters.
Validation is a validator function plus an autovalidate mode
Form validation is wired into the widget rather than left to a surrounding Form. The assembled example in the README shows the pattern, where a validator function returns null when the value is acceptable and a message string when it is not, and a mode setting decides when that check runs:
return Pinput(
defaultPinTheme: defaultPinTheme,
focusedPinTheme: focusedPinTheme,
submittedPinTheme: submittedPinTheme,
validator: (s) {
return s == '2222' ? null : 'Pin is incorrect';
},
pinputAutovalidateMode: PinputAutovalidateMode.onSubmit,
showCursor: true,
onCompleted: (pin) => print(pin),
);The PinputAutovalidateMode setting is the part to notice. With onSubmit, the error state appears when the user finishes entering the code, not on every keystroke, which is the behaviour you want for a code that is not valid until it has enough digits. Combined with the error theme, the error state changes the colour of the offending digit. The validator signature also tells you something about the API contract: it receives the entered string, not a list of digits, so a validator that needs per-digit rules has to parse it.
SMS autofill on iOS and Android
The SMS autofill story differs sharply between the two platforms, and the README is explicit about it. On iOS it works out of the box, by tapping the code on top of the keyboard. On Android, if you are using firebase_auth, you have to set the controller's value in the verificationCompleted callback, so the package holds a controller you own and your authentication layer fills it:
Pinput(
controller: pinController,
);and then in the Firebase flow:
await FirebaseAuth.instance.verifyPhoneNumber(
verificationCompleted: (PhoneAuthCredential credential) {
pinController.setText(credential.smsCode);
},
verificationFailed: (FirebaseAuthException e) {},
codeSent: (String verificationId, int? resendToken) {},
codeAutoRetrievalTimeout: (String verificationId) {},
);For Android apps that do not use Firebase Auth, the README also describes integrations with SMS Retriever and SMS User Consent. Its SMS Retriever example can apply the code without user interaction, while SMS User Consent prompts the user to approve reading the message. Test the integration on an Android device.
Package availability and release history
Adoption reality and release reality are two different things here, and both are worth knowing. The package is MIT licensed and published on pub.dev as pinput, with a homepage, a live demo linked from the README, a Discord channel, and an example application in the repository that carries templates for android, ios, linux, macos, web and windows and multiple demonstration images, so you can see the visual options without reading the code. As of 8 November 2026, pub.dev lists 7.0.0 as the latest stable package release and requires Dart 3.12 for that version. Check the package versions page and changelog for current releases and compatibility before upgrading.
Editorial conclusion
Flutter_Pinput suits a Flutter team that needs a one time code field whose look is defined by the design system rather than by the platform default, and that wants the keyboard, cursor and obscuring behaviour under its own control. Check pub.dev for the current package version and SDK requirements, verify that the README matches the version you install, and read the migration notes when upgrading. Test SMS autofill on Android devices with the authentication or SMS retrieval integration you choose.
Frequently asked questions
How do I add a pin code field in Flutter with Flutter_Pinput?
Create the Pinput widget and pass an onCompleted callback that receives the entered code. The widget takes a defaultPinTheme and per state themes such as focusedPinTheme, submittedPinTheme, followingPinTheme and errorPinTheme, plus an optional validator.
What are the six pin states in Flutter_Pinput?
They are default, focused, submitted, following, disabled and error. Each one can have its own theme, and the pin animates smoothly from one state to another automatically.
How does SMS autofill work with Flutter_Pinput on Android?
If you use firebase_auth, pass a controller to Pinput and set its value in the verificationCompleted callback. The project also documents Android SMS Retriever and SMS User Consent integrations; Retriever can fill the code without user interaction. On iOS, users can tap the suggested code above the keyboard.
How do I validate the code the user typed with Flutter_Pinput?
Pass a validator that returns null for an acceptable value or an error message otherwise, and set pinputAutovalidateMode to control when the check runs. PinputAutovalidateMode.onSubmit runs the validation when the entry is complete rather than on every keystroke.
What is the latest release of the pinput package?
As of 8 November 2026, pub.dev lists 7.0.0 as the latest stable pinput release. Check the package versions page for newer releases and SDK requirements.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/tkko-flutter-pinput)Star history chart for your README
[](https://hysenlabs.com/projects/tkko-flutter-pinput)Was this useful?