gpt4 book ai didi

flutter - flutter :BoxConstraints强制无限高

转载 作者:行者123 更新时间:2023-12-03 05:00:05 24 4
gpt4 key购买 nike

我正在尝试在expand小部件上使用TextFormField属性。

我的代码如下所示:

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。当文本字段的内容溢出时,如何扩展文本字段的高度。

最佳答案

尝试为Container()提供有限的高度。 expands尝试根据您的情况下为TextFormField的 parent 高度调整null的大小。

  body: ListView(
children: <Widget>[
ListTile(
leading: CircleAvatar(
backgroundImage: CachedNetworkImageProvider(
currentUser.photoUrl
)
),
title: Container(
height: 200.0, // Add your own custom height here
//Rest of the code is same
)
),
]
),

关于flutter - flutter :BoxConstraints强制无限高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59675594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com