验证码纯数字键盘

hmxc
小赖 4 years ago
parent 10d89c668b
commit 51571d8798

@ -94,7 +94,8 @@ class _UpdateTelPageState extends State<UpdateTelPage> {
'新号码'.text.black.size(28.sp).make(), '新号码'.text.black.size(28.sp).make(),
TextFormField( TextFormField(
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]*')), FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(11),
], ],
controller: _newTelController, controller: _newTelController,
onChanged: (value) { onChanged: (value) {
@ -147,8 +148,10 @@ class _UpdateTelPageState extends State<UpdateTelPage> {
'验证码'.text.black.size(28.sp).make(), '验证码'.text.black.size(28.sp).make(),
TextFormField( TextFormField(
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[0-9]*')) FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(11),
], ],
keyboardType: TextInputType.number,
controller: _codeController, controller: _codeController,
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.zero, contentPadding: EdgeInsets.zero,

@ -8,6 +8,7 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flustars/flustars.dart' show TextUtil; import 'package:flustars/flustars.dart' show TextUtil;
import 'package:flustars/flustars.dart'; import 'package:flustars/flustars.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart' hide Response; import 'package:get/get.dart' hide Response;
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
@ -145,6 +146,7 @@ class _SignInPageState extends State<SignInPage> {
String hint, String hint,
Widget prefix, Widget prefix,
Widget suffix, Widget suffix,
TextInputType type = TextInputType.number,
TextEditingController controller, TextEditingController controller,
}) { }) {
return Container( return Container(
@ -160,6 +162,11 @@ class _SignInPageState extends State<SignInPage> {
prefix ?? SizedBox(), prefix ?? SizedBox(),
20.wb, 20.wb,
TextField( TextField(
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(11),
],
keyboardType: type,
controller: controller, controller: controller,
onChanged: (_) => setState(() {}), onChanged: (_) => setState(() {}),
decoration: InputDecoration( decoration: InputDecoration(
@ -230,6 +237,7 @@ class _SignInPageState extends State<SignInPage> {
), ),
26.hb, 26.hb,
_buildTextField( _buildTextField(
type: TextInputType.number,
prefix: Image.asset( prefix: Image.asset(
R.ASSETS_IMAGES_CODE_LOGO_PNG, R.ASSETS_IMAGES_CODE_LOGO_PNG,
height: 50.w, height: 50.w,

Loading…
Cancel
Save