Flutter 颤振-文本溢出输入时,Textformfield无法按预期工作
我需要一行输入,但用户可以输入许多字符。。。当输入到input的文本溢出大小时,文本将消失,如下所示: 与其保留同一行,不如让我在注释中向左或向右滚动Flutter 颤振-文本溢出输入时,Textformfield无法按预期工作,flutter,Flutter,我需要一行输入,但用户可以输入许多字符。。。当输入到input的文本溢出大小时,文本将消失,如下所示: 与其保留同一行,不如让我在注释中向左或向右滚动 Row(children: [ Expanded( flex: 8, child: TextFormField( decoration: InputDecoration( contentPadding: EdgeInsets.all(20.0), fille
Row(children: [
Expanded(
flex: 8,
child: TextFormField(
decoration: InputDecoration(
contentPadding: EdgeInsets.all(20.0),
filled: true,
fillColor: Theme.of(context).scaffoldBackgroundColor,
border: OutlineInputBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
bottomLeft: Radius.circular(30.0),
),
borderSide: BorderSide(
width: 0,
style: BorderStyle.none,
),
),
labelText: 'Type your comment',
labelStyle: TextStyle(color: Colors.grey),
),
inputFormatters: [
LengthLimitingTextInputFormatter(102),
],
),
),
Expanded(
flex: 3,
child: RaisedButton(
color: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(30.0),
bottomRight: Radius.circular(30.0)),
),
child: Text(
'Comment',
style: Theme.of(context)
.textTheme
.caption
.copyWith(fontSize: 9, color: Theme.of(context).buttonColor),
),
onPressed: () {},
),
)
]),
您可以在容器中包装textField,还可以将最大和最小行设置为“1”,作为textField内部的属性
这对我很有用:)改用TextformField,并用内容填充字段
InputDecorationTheme InputDecorationTheme(){
OutlineInputBorder OutlineInputBorder=OutlineInputBorder(
边界半径:边界半径。圆形(35),
borderSide:borderSide(颜色:颜色(0xff0D3552)),
加丁:10,
);
返回InputDecorationTheme(
浮动LabelBehavior:浮动LabelBehavior.always,
contentPadding:EdgeInsets.all(25),
enabledBorder:outlineInputBorder,
聚焦顺序:大纲输入边框,
边框:大纲输入边框,
);
}
共享代码片段共享代码。添加的代码片段无效。。。我分享了我使用的代码。。。也许我的代码有错误,你应该删除输入格式化程序,添加textFormField的maxLines、minLines、maxLength参数。。虽然我已经通读了上面的代码,但我找不到任何与这个问题无关的东西。InputFormators在dart pad online中执行时抛出错误,但在删除它并添加上述建议后,对我来说效果很好。删除输入格式化程序并添加maxLines:1、minLines:1、maxLength:255无效。您是否尝试在不同的操作系统或设备中运行代码?