颤音:我的控制器在其余的输入字段中显示
提取我的TextFormField小部件的方法后,我想使用TextedingController添加控制器,问题是如何将其放置在每个字段中,但是我将其全部提取到了方法,但是如果我输入了所有显示的内容,则输入字段:
这是我试图使用控制器的注册部分,但是我
Container buildSignupSection() {
return Container(
margin: EdgeInsets.only(top: 30),
child: Form(
key: _signUpFormKey,
child: Column(
children: [
buildTextField(
"xpresschop",
"Name",
true,
false,
false,
),
buildTextField(
"[email protected]",
"email",
false,
false,
true,
),
buildTextField(
"......",
"password",
false,
true,
false,
),
buildTextField(
"......",
"Confirm password",
false,
true,
false,
),
],
),
),
);
}
将其保留在下面
Widget buildTextField(String hintText, String labelText, bool isName,
bool isPassword, bool isEmail) {
return Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Column(
children: [
TextFormField(
controller: ,
autocorrect: isAutoCorrect,
obscureText: isPassword,
After extracting the method of my textformfield widget, I want to add controller to it using the TextEditingController,the issue is how to placed it in each fields but i have extracted it all to a method, but if I type anything it shows for all the input fields:
This is the signup part where I am trying to use the controller, but i kept it below
Container buildSignupSection() {
return Container(
margin: EdgeInsets.only(top: 30),
child: Form(
key: _signUpFormKey,
child: Column(
children: [
buildTextField(
"xpresschop",
"Name",
true,
false,
false,
),
buildTextField(
"[email protected]",
"email",
false,
false,
true,
),
buildTextField(
"......",
"password",
false,
true,
false,
),
buildTextField(
"......",
"Confirm password",
false,
true,
false,
),
],
),
),
);
}
How will i add it here
Widget buildTextField(String hintText, String labelText, bool isName,
bool isPassword, bool isEmail) {
return Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Column(
children: [
TextFormField(
controller: ,
autocorrect: isAutoCorrect,
obscureText: isPassword,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将不同的控制器添加到每个TextField,U可以将控制器作为参数传递到buildTextField方法,
然后您的小部件将是:
Add different controller to each textfield, u can pass controller as parameter to buildTextField method
then your widget would be: