【发布时间】:2020-04-27 17:52:17
【问题描述】:
我正在尝试在 TextFormField 小部件上使用 expand 属性。
我的代码如下所示:
body: ListView(
children: <Widget>[
ListTile(
leading: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
currentUser.photoUrl
)
),
title: Container(
color: Colors.blue,
width: 250.0,
child: TextFormField(
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
color: Colors.white
),
cursorColor: Colors.white,
maxLines: null,
minLines: null,
expands: true,
controller: captionController,
decoration: InputDecoration(
hintText: 'Write something...',
border: InputBorder.none,
hintStyle: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold
),
fillColor: Colors.blue
)
)
)
),
]
)
我遇到的问题是,每次运行代码时,我都会收到错误消息:BoxConstraints forces an infinite height。请问当文本字段的内容长度溢出时,如何扩展文本字段的高度。
【问题讨论】: