TextField(
autofocus:true,...
)
GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(_focusNode);
},...
)
_focusNode.unfocus();
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,)