flutter_verification_box 1.0.3

  • Readme
  • Changelog
  • Installing
  • 80

使用 #

Container(
  height: 45,
  child: VerificationBox(),
)

效果如下:

设置验证码的数量,比如设置4个:

VerificationBox(
  count: 4,
)

效果如下:

设置样式,包括边框的颜色、宽度、圆角:

VerificationBox(
  borderColor: Colors.lightBlue,
  borderWidth: 3,
  borderRadius: 50,
)

效果如下:

除了“盒子”样式,还支持下划线样式:

VerificationBox(
  type: VerificationBoxItemType.underline,
)

效果如下:

设置数字的样式:

VerificationBox(
  textStyle: TextStyle(color: Colors.lightBlue),
)

效果如下:

显示光标,设置光标样式:

VerificationBox(
  showCursor: true,
  cursorWidth: 2,
  cursorColor: Colors.red,
  cursorIndent: 10,
  cursorEndIndent: 10,
)

效果如下:

还可以设置光标为整个边框,如下:

VerificationBox(
  focusBorderColor: Colors.lightBlue,
)

效果如下:

终极大招,如果你觉得这个效果不好,你可以自定义decoration

VerificationBox(
    decoration: BoxDecoration(
      image: DecorationImage(image: AssetImage('images/box.png')),
    ),
    textStyle: TextStyle(color: Colors.lightBlue),
  ),
)

效果如下:

验证码输入完成后回调onSubmitted,用法如下:

VerificationBox(
  onSubmitted: (value){
    print('$value');
  },
)

输入完成后,默认键盘消失,设置为不消失,代码如下:

VerificationBox(
  unfocus: false,
)

[1.0.3] - TODO: 增加type类型export. #

  • TODO: 增加type类型export.

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_verification_box: ^1.0.3

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:flutter_verification_box/verification_box.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
72
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_verification_box that is a package requiring null.

Health suggestions

Format lib/src/verification_box.dart.

Run flutter format to format lib/src/verification_box.dart.

Format lib/src/verification_box_cursor.dart.

Run flutter format to format lib/src/verification_box_cursor.dart.

Format lib/src/verification_box_item.dart.

Run flutter format to format lib/src/verification_box_item.dart.

Format lib/verification_box.dart.

Run flutter format to format lib/verification_box.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and flutter_verification_box.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test