如何解决如果用户在文本字段中输入值,如何更新文本小部件值
我想在用户在文本字段中输入文本时更新文本小部件值,这就是我正在做的事情。
String getemail="";
_userDetails() async{
SharedPreferences myPrefs=await SharedPreferences.getInstance();
setState(() {
getemail=myPrefs.getString('email');
});
}
TextEditingController email=new TextEditingController();
Column(children: <Widget>[
TextField(
onChanged: (value) {
setState(() {
valueText = value;
});
},controller: email,decoration: InputDecoration(hintText: getemail,icon: Icon(Icons.email)),),Container(
padding: EdgeInsets.fromLTRB(30,260,0),child: Row(children: <Widget>[
Icon(Icons.email,color: Colors.blue,size: 27,Text(email.text==""?getemail:email.text,style:TextStyle(fontSize: profileFontsize))
],
它没有在文本小部件上打印任何内容,请帮助如何做到这一点。
更新:
奇怪!此 email.text==""?getemail:email.text
条件以前不起作用,但现在起作用了!!
解决方法
Text(email.text == " " ? getemail : valueText,style:TextStyle(fontSize: profileFontsize),)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。