1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| class HYContentBody extends StatelessWidget { final userNameController = TextEditingController(); final passwordController = TextEditingController(); @override Widget build(BuildContext context) { return Theme( data:ThemeData( primaryColor: Colors.red, ), child: Padding( padding: EdgeInsets.all(10), child: Column( children: <Widget>[ Column( children: <Widget>[ TextField( controller: userNameController, // keyboardType: TextInputType.number, //键盘类型 decoration: InputDecoration( icon: Icon(Icons.people), labelText: "用户名", // border: OutlineInputBorder(), border: InputBorder.none, hintText: "请输入用户名", filled: true, fillColor: Colors.red[100] ), onChanged: (value){ print("onChanged:$value"); }, onSubmitted: (value){ print("onSubmitted:$value"); }, ), SizedBox(height:20), TextField( controller: passwordController, decoration: InputDecoration( icon: Icon(Icons.lock), labelText: "密码", hintText: "请输入密码", border: OutlineInputBorder( borderSide: BorderSide( color: Colors.red, width: 2 ) ) ), onChanged: (value){ print("password onChange:$value"); }, ), SizedBox(height:20), Container( // width: 200, width: double.infinity, height: 50, child: FlatButton( color: Colors.purple, child: Text("登录",style: TextStyle(color: Colors.white, fontSize: 20),), onPressed: (){ final userName = userNameController.text; final password = passwordController.text; print("userName;$userName, password:$password");
//清空数据 userNameController.clear(); passwordController.clear(); }, ), ), ], ), ], ), ), ); } }
|