答案 0 :(得分:1)
改为使用labelText
TextFormField(
controller: fullNameController,
validator: (value) {
if (value.trim().isEmpty) {
return Lang.enterFullName;
}
return null;
},
decoration: InputDecoration(
labelText: Lang.fullName,
prefixIcon: Icon(Icons.person),
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
),
答案 1 :(得分:1)
您可能必须添加一个侦听器来侦听焦点更改:
FocusNode myFocusNode = FocusNode();
myFocusNode.addListener( () {
setState((){});
}
然后,在InputDecoration内部更新值:
hintText: myFocusNode.hasFocus ? hintText : ''