【发布时间】:2026-01-23 08:35:01
【问题描述】:
当用户在文本字段中输入文本时,我想更新文本小部件的值,这就是我正在做的事情。
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, 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 条件以前不起作用,但现在它起作用了!!
【问题讨论】:
标签: flutter text controller textfield