使用其他 TextField TextEditingController.text 值 + 额外字符串更新 TextEditingController.text

Update TextEditingController.text with other TextFields TextEditingController.text values + extra String

我的应用程序中有名字和姓氏TextFormField

我希望禁用的电子邮件字段使用 name fieldlast name field + company domain 中写入的值自动完成:@company.com

  TextEditingController emailTextController = TextEditingController();
  TextEditingController nameTextController = TextEditingController();
  TextEditingController lastNameTextController = TextEditingController();
 @override
  onInit() async {
emailTextController = emailNameTextController;
    super.onInit();
  }

但我想要的是 emailTextController.text 最后还有 @company.com

  @override
  onInit() async {
    emailTextController.text = emailNameTextController.text + '@company.com';
    super.onInit();
  }

email field 的值不会更新为来自 nameField

的值

您可以在 lastName textfield

上使用 onSubmitedonChanged
TextField(
  controller: lastNameTextController ,
  onSubmitted: (text) {
  emailTextController.text = nameTextController.text + lastNameTextController.text + '@company.com';
  },
//OR us this
  onChanged(){
 emailTextController.text = nameTextController.text + lastNameTextController.text + '@company.com';
},
 
  textInputAction: TextInputAction.send,
)