Flutter mobile phone number verification
Text box Edge box
EnabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(5)), borderSide: BorderSide( color: Colors.white54, width: , 1.2),), / / click on the state line box focusedBorder: OutlineInputBorder (borderRadius: borderRadius. All (Radius. The circle (5)). BorderSide: borderSide (color: color.blue, width:1.2,), / / error state line box errorBorder: OutlineInputBorder (borderRadius: borderRadius. All (Radius. The circular (5)). BorderSide: borderSide (color: colors. red, width:1.2,)), // Error duration focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.all(Radius.circular(5)), borderSide: BorderSide( color: Color.red, width: 1.2,)), // errorStyle: TextStyle(color: color.red, fontSize: 16), hintStyle: TextStyle(color: colors.white54), hintText: widget.hintText, // Add clear button suffixIcon: (_text.length > 0)? IconButton(icon: icon (icon.clear), color: colors.blue, onPressed: () {// Clear textConttoller.clear(); }, ) : null, ), class TelePhone extends StatefulWidget { @override State<TelePhone> createState() => _TelePhoneState(); } class _TelePhoneState extends State<TelePhone> {final _formKey = GlobalKey<FormState>(); var phone = ''; Var isShowClear = false; Get validatePhone => NULL; get foucsNodeListener => null; @override void initState() { super.initState(); Utils. Speak (' Please enter your phone number '); } @override void dispose() {// Remove focus listener super.dispose(); utils.stoptts(); } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomPadding: False, // The input box stands against the keyboard to prevent screen overflow body: Container(child: Stack(alignment: alignment. Center, children: [Container(padding: EdgeInsets.fromLTRB(100, 100, 80, 100), color: Colors.black54, child: Row( children: [ Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( padding: EdgeInsets.fromLTRB(200, 300, 200, 50), margin: EdgeInsets.all(20), color: Colors.black54, child: Column(children: [ Column( mainAxisAlignment: MainAxisAlignment.end, children: [ Container( margin: EdgeInsets.only(top: 100), child: FlatButton( child: Text(' confirm ', style: TextStyle(color: color.white, fontSize: 20),), onPressed: () {if (_formkey. CurrentState. The validate ()) {/ / only input through the verification, can perform to _formkey here. The currentState. The save (); Navigator.push(context, MaterialPageRoute(builder: (conext) { return LivePeoplePage(); }) ); } }, color: Color(0xFF8599cb), padding: EdgeInsets.fromLTRB(100, 15, 100, 15), shape: RoundedRectangleBorder( side: BorderSide.none, borderRadius: BorderRadius.all( Radius.circular(50), ) ), ), ) ], ) ]), ), ], ), ], ), ), Positioned( width: 400, child: Form( key: _formKey, child: KmTextFormField(// Input mode is mobile number keyboardType: TextInputType. Phone, hintText: "Click here to enter mobile phone number ", // Mobile phone number input box validator: (value) { RegExp reg = new RegExp(r'^\d{11}$'); if (! Reg. HasMatch (value)) {return 'please enter 11 phone number;} return null;},),),),),),),); }}Copy the code
The results