Flutter 颤振文本表单字段:对齐输入字段左侧的文本描述
早上好,我正在Flutter中创建TextFormFields,我有点沮丧,因为我不能在输入的左侧保留文本 输入该字段时,hintText将消失 prefixText仅在输入字段后显示 prefixIcon完全符合我的要求,但我想要文本而不是图标 上图使用prefixIcon和hintTextFlutter 颤振文本表单字段:对齐输入字段左侧的文本描述,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,早上好,我正在Flutter中创建TextFormFields,我有点沮丧,因为我不能在输入的左侧保留文本 输入该字段时,hintText将消失 prefixText仅在输入字段后显示 prefixIcon完全符合我的要求,但我想要文本而不是图标 上图使用prefixIcon和hintText 请问,有人对如何用永久文本替换我当前的图标有什么建议吗?感谢您提供的一切帮助。尝试在装饰中使用prefixText属性 TextField( controller: _textController
请问,有人对如何用永久文本替换我当前的图标有什么建议吗?感谢您提供的一切帮助。尝试在装饰中使用
prefixText
属性
TextField(
controller: _textController,
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: 'Enter a valid ZIP-Code',
errorText: _hasInputError ? "ZIP-Code is too short" : null,
counterText: _textController.text.length.toString(),
helperText: "ZIP-Code of shipping destination",
labelText: "ZIP-Code",
prefixText: "DE - ",
suffixIcon: Icon(Icons.airport_shuttle),
),
),
参考此
我认为在使用
装饰时不能使用前缀
prefixIcon接受小部件类型,因此如果需要,可以将小部件传递给它
TextFormField(
controller: _passwordController,
decoration: InputDecoration(
hintText: "Password",
prefixIcon: CircleAvatar(
backgroundImage: NetworkImage(kDefaultProfilePicture),
) // You can replace this with a Text("") widget,
suffixIcon: IconButton(
icon: Icon(Icons.visibility),
onPressed: () {},
),
),
),
正如我在问题中提到的,prefixText仅在单击输入表单时出现。这并不能帮助用户看到他们应该事先输入的内容。但是谢谢你的建议。