【发布时间】:2020-06-01 04:51:33
【问题描述】:
我正在做一个 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,
),
【问题讨论】:
-
您好,感谢您的回复,我认为这不适用于文本字段标签,
-
为什么不喜欢普通的html,你添加一个标题属性,当有人将鼠标悬停在它上面时,标签就会出现,一个技巧。
-
我确信
labelText: "A VERY VERY VERY VERY VERY VERY LONG LABEL",需要一个字符串,你不能给它分配一个小部件 -
maxLines属性可用于您的示例中提到的TextFormField。检查这个,stackoverflow.com/questions/45900387/… 和这个,stackoverflow.com/questions/43348254/…
标签: flutter