gpt4 book ai didi

android - Flutter渲染listView溢出

转载 作者:IT王子 更新时间:2023-10-29 07:00:23 24 4
gpt4 key购买 nike

我有一个用于呈现一系列消息的聊天应用程序的代码。问题是页面显示正常,但在尝试发送消息时出现渲染溢出。就好像我的输入一直在上升,而不是在我显示的键盘上自行设置。

这是我渲染页面的代码

 return Scaffold(
body: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: ListView.builder(
itemBuilder: (_, index) => _messages[index],
itemCount: _messages.length,
//El reverse hace que vaya de abajo hacia arriba
reverse: true,
padding: EdgeInsets.all(6.0),
),
),
Divider(
height: 1.0,
),
Container(
child: _buildComposer(),
decoration: BoxDecoration(color: Theme.of(context).cardColor),
)
],
),
);

这里我有我认为错误的输入代码

 Widget _buildComposer() {
return IconTheme(
data: IconThemeData(color: Theme.of(context).accentColor),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 9.0),
child: Row(
// mainAxisSize: MainAxisSize.min,
children: <Widget>[
Flexible(
child: TextField(
controller: _textController,
onChanged: (String texto) {
setState(() {
_isWriting = texto.length > 0;
});
},
onSubmitted: _enviarMensaje,
decoration:
InputDecoration.collapsed(hintText: "Envie un mensaje!"),
),
),
Container(
margin: EdgeInsets.symmetric(horizontal: 3.0),
child: IconButton(
icon: Icon(Icons.message),
onPressed: _isWriting
? () => _enviarMensaje(_textController.text)
: null,
),
)
],
),
),
);

这是我在输入中单击以写一些消息后的初始渲染打印捕获

enter image description here

enter image description here

这是我的日志,应该很容易理解我应该采用的方法,但我没有任何运气。

enter image description here仅供引用:我已经尝试过这种方法但似乎没有用 StackOverflow answer on rendering

我已经阅读了 flutter.io 文档,但我并不理解整个 ListView 理论。如果您有一些见解,我也将不胜感激,这样我就能深入了解它的行为方式。

最佳答案

resizeToAvoidBottomPadding: false 可能有帮助.. 看看 here

正如@diegoveloper 的评论,它不会调整大小,这意味着它不会显示键盘后面的内容。根据您的用例,您可以在上面的链接中选择选项 1 或 2

关于android - Flutter渲染listView溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51987558/

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