pin_input_text_field 2.0.0

pub package

pin_input_text_field #

中文版点我 PinInputTextField is a TextField widget to help display different style pin.

Notice after Version 2.0.0 #

Please set the selection when you set the text programmatically, just like this.

I can't set the selection in lib code, because if I did it will cause dead loop in iOS.

If you have any idea, please make a Pull Request.

Example #

Decoration #

UnderlineDecoration

BoxLooseDecoration

BoxTightDecoration

Installing #

Install the latest version from pub.

Usage #

Attributes #

Customizable attributes for PinInputTextField

Attribute Name Example Value Description
pinLength 6 The max length of pin, the default is 6
onSubmit (String pin){} The callback will execute when user click done, sometimes is not working in Android.
decoration BoxLooseDecoration Decorate the pin, there are 3 inside styles, the default is BoxLooseDecoration
inputFormatters WhitelistingTextInputFormatter.digitsOnly Just like TextField's inputFormatter, the default is WhitelistingTextInputFormatter.digitsOnly
keyboardType TextInputType.phone Just like TextField's keyboardType, the default is TextInputType.phone
pinEditingController PinEditingController Controls the pin being edited. If null, this widget will create its own PinEditingController
autoFocus false Same as TextField's autoFocus, the default is false
focusNode FocusNode Same as TextField's focusNode
textInputAction TextInputAction.done Same as TextField's textInputAction, not working in digit mode.
enabled true Same as TextField's enabled, the default is true

ObscureStyle #

/// Determine whether replace [obscureText] with number.
final bool isTextObscure;
/// The display text when [isTextObscure] is true, emoji supported
final String obscureText;

Known Issue #

The PinEditingController listener will execute more than once when programmatically set text, you can filter some duplicate values in your code.

[2.0.0] - 2019/08/12

  • Update: parameter pinEditingController renamed to controller.
  • Remove: remove the PinEditingController class, just simply use TextEditingController.
  • Fix: support dynamically changing of length & controller.
  • New: allow custom key.
  • Notice: Please set the selection when you set the text programmatically.

[1.0.1] - 2019/06/23

  • Fix: fix fatal error

[1.0.0] - 2019/06/23

  • Update: obscure text support emoji now.

[0.4.0] - 2019/05/23

  • New: add 'enable' to control pin input.

[0.3.1] - 2019/05/12

  • Update: complete example readme.md and pubspec.yaml.

[0.3.0] - 2019/04/09

  • New: no need to correct user's input.
  • New: align actual text in center to make popup window more natural.
  • New: obscure mode is always on now.
  • New: add textInputAction to control TextInputAction.

Breaking Change #

  • PinEditingController constructor must provide pinLength.
  • PinEditingController constructor provide new field autoDispose to simplify dispose.
  • PinTextField constructor remove width and height field, if you want customize size of the PinInputTextField, you can wrap a Container widget.

[0.2.1] - 2019/01/20

  • change default color of underlineDecoration from Colors.Black to Colors.cyan.
  • add more detail example.

[0.2.0] - 2019/01/20

  • add keyboardType & inputFormatters control.
  • add autoFocus & focusNode control.
  • add controller to assign pin.

[0.1.1] - 2019/01/09

  • change license from MIT to Apache.

[0.1.0] - 2019/01/09

  • add comment to help understand source code.
  • add obscure style to be more customize.
  • add onPinChanged to observe the text changed.
  • add solidColor to set background color in BoxLooseDecoration & BoxTightDecoration.
  • add enteredColor for UnderlineDecoration&BoxLooseDecoration.
  • remove const default variable in PinInputTextField.
  • fix wrong place in painting

[0.0.1] - 2018/12/24.

  • first commit.

example/README.md

example/main.dart #

Full examples see this

import 'package:pin_input_text_field/pin_input_text_field.dart';

PinInputTextField(
                pinLength: 4,
                decoration: _pinDecoration,
                controller: _pinEditingController,
                autoFocus: true,
                textInputAction: TextInputAction.go,
                onSubmit: (pin) {
                  debugPrint('submit pin:$pin');
                },
              )

Use this package as a library

1. Depend on it

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


dependencies:
  pin_input_text_field: ^2.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:pin_input_text_field/pin_input_text_field.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
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]
95
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

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 1.14.12
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