我正在做一个Flutter项目,我用TextFormField
实现了一个表单,我们有一些标签很长的字段,因为它们太长了,Flutter我们剪切文本并添加。..最后,是否可以设置溢出,使标签文本为2行,而不是切断文本?
TextFormField(
key: GlobalKey(),
controller: _textEditingController,
focusNode: _focusNode,
obscureText: true,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.done,
decoration: widget.decorations.copyWith(
errorText:
widget.field["error"] != null ? widget.field["error"] : null,
labelText: "A VERY VERY VERY VERY VERY VERY LONG LABEL",
hintText: widget.field["helpText"],
helperStyle: TextStyle(
color: Colors.black,
),
),
onFieldSubmitted: widget.onFieldSubmitted,
onSaved: widget.onSaved,
onTap: widget.onTap,
),
3条答案
按热度按时间r1zhe5dt1#
我发现this solution当我试图解决同样的问题。请尝试使用
decoration
属性,并将errorMaxLines
属性设置为大于1的数字。例如:jtoj6r0c2#
对我很有效。...
文本表单字段(
bd1hkmkf3#
其他的答案我都想了,这是唯一一个对我有用的。容器有一个transform属性,允许我们使用负边距,在装饰中使用它可以为两行标签给予更多的空间,而不会侵占您的字段。