Skip to content
项目

TinoGuo/pin_input_text_field

在 GitHub 查看

关于

用于显示不同样式 PIN 码的 textField 组件

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README_CN.md

原文

pub package GitHub GitHub top language

pin_input_text_field

English PinInputTextField是一个Flutter平台上用来展示不同样式的验证码,简单好用!支持所有flutter支持的平台

注意 🚨

对于flutter版本在3.7.0以下的请使用4.4.1

特点 🌟

  • 允许你最大化自由的定制任意Shape!
  • 内置4种常用验证码风格
  • 支持隐藏明文
  • 支持填充色
  • 支持输入色
  • 支持光标
  • 理论上支持所有TextField的属性
  • 支持Flutter所有平台

例子 🌰

现在你可以通过浏览器直接访问这个网址来预览效果,而不需要任何安装。

装饰器

UnderlineDecoration

BoxLooseDecoration

BoxTightDecoration

CircleDecoration

安装 ✍️

从pub安装最新版.

使用

属性

PinInputTextField的自定义属性

属性名 参考值 描述
pinLength 6 验证码的长度, 默认是6
onSubmit (String pin){} 用户点击键盘右下角时触发,Android平台有时不一定生效
decoration BoxLooseDecoration 内置三种验证码样式,默认是BoxLooseDecoration
inputFormatters WhitelistingTextInputFormatter.digitsOnly 跟TextField的inputFormatters一样, 默认是WhitelistingTextInputFormatter.digitsOnly
keyboardType TextInputType.phone 跟TextField的keyboardType一样, 默认是TextInputType.phone
pinEditingController PinEditingController 控制和监听用户输入。如果为空,内部会创建一个默认的控制器
autoFocus false 跟TextField的autoFocus一样, 默认是false
focusNode FocusNode 跟TextField的focusNode一样.
textInputAction TextInputAction.done 跟TextField的textInputAction一样, 数字模式下无效
enabled true 跟TextField的enabled一样, 默认是true
onChanged (String pin){} 跟TextField的onChanged一样
textCapitalization TextCapitalization.words 跟TextField的textCapitalization一样
cursor Cursor.disabled() 验证码的游标,默认不开启

表单验证

请使用PinInputTextFormField来做表单验证.

所有内置样式默认在 PIN 框与验证错误文字之间预留 8 个逻辑像素,可以在样式中修改:

BoxLooseDecoration(
  errorTextSpacing: 16, // 不配置时默认为 8
  strokeColorBuilder: const FixedColorBuilder(Colors.black),
)

密码模式

/// 是否需要替换[obscureText]开启密码模式.
final bool isTextObscure;
/// 当[isTextObscure]开启时,替换验证码的字符串,支持emoji
final String obscureText;

已知问题 🥶

目前PinEditingController的Listener会在手动设置text值时执行多次,可以在应用层的代码上过滤下

准备发布版本

请先在已更新的 checkout 中做一次 dry run:

./scripts/prepare_release.sh --dry-run
./scripts/prepare_release.sh patch

脚本支持 patch、minor、major,也支持直接指定版本号,例如 4.5.3。它会刷新远端 tag, 如果最新 tag 无法匹配当前历史就会停止;同时也能处理 pubspec.yaml 版本高于已有 tag 的历史情况。 实际执行 patch 时,要求本地 master 干净且与 origin/master 一致;脚本只更新根目录的 pubspec.yaml 与 CHANGELOG.md,自动 commit 和 push,随后 push 下一个不带 v 的版本 tag, 并用生成的 release notes 创建 GitHub Release。它不会修改 example/pubspec.yaml。

release.yml 会为普通或带 v 的 SemVer tag 创建 GitHub Release;publish.yml 则会通过 pub.dev environment 发布普通 SemVer tag。首次自动发布前,需要先在 pub.dev 为此仓库配置 GitHub Actions 发布。

License

Copyright 2019 Tino Guo.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

探索相关项目

加载中…