diff --git a/lib/pages/personal/update_tel_page.dart b/lib/pages/personal/update_tel_page.dart index 3f8c9a24..9b826cb2 100644 --- a/lib/pages/personal/update_tel_page.dart +++ b/lib/pages/personal/update_tel_page.dart @@ -94,7 +94,8 @@ class _UpdateTelPageState extends State { '新号码'.text.black.size(28.sp).make(), TextFormField( inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9]*')), + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(11), ], controller: _newTelController, onChanged: (value) { @@ -147,8 +148,10 @@ class _UpdateTelPageState extends State { '验证码'.text.black.size(28.sp).make(), TextFormField( inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp(r'[0-9]*')) + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(11), ], + keyboardType: TextInputType.number, controller: _codeController, decoration: InputDecoration( contentPadding: EdgeInsets.zero, diff --git a/lib/pages/sign/sign_in_page.dart b/lib/pages/sign/sign_in_page.dart index a36e6185..84de872d 100644 --- a/lib/pages/sign/sign_in_page.dart +++ b/lib/pages/sign/sign_in_page.dart @@ -8,6 +8,7 @@ import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart' show TextUtil; import 'package:flustars/flustars.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart' hide Response; import 'package:power_logger/power_logger.dart'; @@ -145,6 +146,7 @@ class _SignInPageState extends State { String hint, Widget prefix, Widget suffix, + TextInputType type = TextInputType.number, TextEditingController controller, }) { return Container( @@ -160,6 +162,11 @@ class _SignInPageState extends State { prefix ?? SizedBox(), 20.wb, TextField( + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(11), + ], + keyboardType: type, controller: controller, onChanged: (_) => setState(() {}), decoration: InputDecoration( @@ -230,6 +237,7 @@ class _SignInPageState extends State { ), 26.hb, _buildTextField( + type: TextInputType.number, prefix: Image.asset( R.ASSETS_IMAGES_CODE_LOGO_PNG, height: 50.w,