pin_code_text_field 1.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 84

pin_code_text_field

Pub

It's a Flutter widget for entering pin code. Suitable for use cases such as login and OTP.

Usage

API

nametypedefaultdescription
maxLengthint4The total length of pin number & the number of pin boxes.
hideCharacterboolfalseShow or hide the pin code.
highlightboolfalsehighlight the focused pin box.
highlightColorColorColors.blackSet color of the focused pin box.
pinBoxDecorationBoxDecorationProvidedPinBoxDecoration._defaultPinBoxDecorationCustomization for the individual pin boxes. Check ProvidedPinBoxDecoration for possible options.
pinTextStyleTextStyleTextStyle for styling pin characters.
maskCharacterString"\u25CF"Special character to mask the pin code. Will only work if hideCharacter is set to true.
pinBoxHeightdouble70.0Height of pin boxes.
pinBoxWidthdouble70.0Width of pin boxes.
onDonevoid Function(String)Callback when the max length of pin code is reached.
hasTextBorderColorColorColors.blackSet color of pin box containing text.
pinTextAnimatedSwitcherTransitionFunction(Widget child, Animation<double> animation)Animation of text appearing/disappearing, you can write your own or use a few presets: 1. PinCodeTextField.awesomeTransition 2. PinCodeTextField.defaultScalingTransition 3. PinCodeTextField.defaultRotateTransition
pinTextAnimatedSwitcherDurationDurationconst Duration()Duration of pinTextAnimatedSwitcherTransition. Check ProvidedPinBoxTextAnimation for possible options.
errorBorderColorColorColors.redHighlight all textboxes to this color if hasError is set to true
onTextChangeFunction(String)callback that returns a text on input
hasErrorboolfalseset all border color to errorBorderColor

Example


class MyHomePageState extends State<MyHomePage> {
  TextEditingController controller = TextEditingController();
  String thisText = "";

  bool hasError = false;
  String errorMessage;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Pin Code Text Field Example"),
      ),
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.only(bottom: 60.0),
              child: Text(thisText, style: Theme.of(context).textTheme.title),
            ),
            PinCodeTextField(
              controller: controller,
              hideCharacter: true,
              highlight: true,
              highlightColor: Colors.blue,
              defaultBorderColor: Colors.black,
              hasTextBorderColor: Colors.green,
              maxLength: 5,
              hasError: hasError,
              onTextChanged: (text) {
                setState(() {
                  hasError = false;
                });
              },
              pinTextStyle: TextStyle(fontSize: 30.0),
              pinTextAnimatedSwitcherTransition: PinCodeTextField.defaultScalingTransition,
              pinTextAnimatedSwitcherDuration: Duration(milliseconds: 500),
            ),
            Visibility(
              child: Text(
                "Wrong PIN!",
                style: TextStyle(color: Colors.red),
              ),
              visible: hasError,
            ),
            Padding(
              padding: const EdgeInsets.only(top: 32.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  MaterialButton(
                    color: Colors.blue,
                    textColor: Colors.white,
                    child: Text("SUBMIT"),
                    onPressed: () {
                      setState(() {
                        this.thisText = controller.text;
                      });
                    },
                  ),
                  MaterialButton(
                    color: Colors.red,
                    textColor: Colors.white,
                    child: Text("SUBMIT Error"),
                    onPressed: () {
                      setState(() {
                        this.hasError = true;
                      });
                    },
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}

Wishlist

  1. Localization (L-R, R-L)
  2. Highlight animation
  3. Pin Box animation

Star 🌟 to show support!

pin usage pin usage

More information

documentation.

[1.1.2] - 17 December 2018

  • Refactored provided PinBoxDecoration to ProvidedPinBoxDecoration
  • Refactored provided PinBoxTextAnimation to ProvidedPinBoxTextAnimation

[1.1.1] - 15 December 2018

  • minor bug fix

[1.1.0] - 15 December 2018

Added customizable animation on texts

  • added errorBorderColor
  • added hasTextBorderColor
  • added onTextChanged
  • added pinTextAnimatedSwitcherTransition
  • added pinTextAnimatedSwitcherDuration

[1.0.0] - 11 December 2018

  • Added a few text properties
    • maskCharacter
    • pinCodeTextStyle

[0.1.1] - 16 October 2018

  • First release of plugin

[0.0.3] - 16 October 2018

  • Update with customizable BoxDecorator

example/README.md

example

Example of App using pin code

Getting Started

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pin_code_text_field: ^1.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pin_code_text_field/pin_code_text_field.dart';
  
Version Uploaded Documentation Archive
1.1.2 Dec 17, 2018 Go to the documentation of pin_code_text_field 1.1.2 Download pin_code_text_field 1.1.2 archive
1.1.1 Dec 15, 2018 Go to the documentation of pin_code_text_field 1.1.1 Download pin_code_text_field 1.1.1 archive
1.0.1 Dec 11, 2018 Go to the documentation of pin_code_text_field 1.0.1 Download pin_code_text_field 1.0.1 archive
1.0.0 Dec 11, 2018 Go to the documentation of pin_code_text_field 1.0.0 Download pin_code_text_field 1.0.0 archive
0.1.3 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.1.3 Download pin_code_text_field 0.1.3 archive
0.1.2 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.1.2 Download pin_code_text_field 0.1.2 archive
0.1.1 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.1.1 Download pin_code_text_field 0.1.1 archive
0.1.0 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.1.0 Download pin_code_text_field 0.1.0 archive
0.0.3 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.0.3 Download pin_code_text_field 0.0.3 archive
0.0.2 Oct 16, 2018 Go to the documentation of pin_code_text_field 0.0.2 Download pin_code_text_field 0.0.2 archive

All 11 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Jan 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.10
  • Flutter: 1.1.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/pin_code_text_field.dart. (-0.50 points)

Analysis of lib/pin_code_text_field.dart reported 1 hint:

line 156 col 11: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test