android - Flutter 渲染 listView 溢出
问题描述
我有一个用于呈现一系列消息的聊天应用程序的代码。问题是页面显示正常,但是在尝试发送消息时出现渲染溢出。就像我的输入一直在上升,而不是在我显示的键盘上设置自己。
这是我渲染页面的代码
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,
),
)
],
),
),
);
}
这是我在输入中单击以编写一些消息后用于初始渲染的打印捕获
这是我的日志,应该很容易理解我应该采取的方法,但我没有任何运气。
仅供参考:我已经尝试过这种方法,但似乎没有 在渲染时使用 StackOverflow 答案
我已经阅读了 flutter.io 文档,但我不了解整个 listview 理论。如果您有一些见解,我也将不胜感激,这样我就可以深入了解它的行为方式。
解决方案
resizeToAvoidBottomPadding: false
可能有帮助..看看这里
正如@diegoveloper 的评论,它不会调整大小,这意味着它不会在键盘后面显示内容。根据您的用例,您可以在上面的链接中选择选项 1 或 2
推荐阅读
- wpf - 每次 5 秒后 MediaElement 冻结
- javascript - 如何在我的 HTML标记顶部的 JS 中显示捕捉网格?
- javascript - 如何重新初始化所需的模块?
- sql - 如何选择字符长度和列值?
- javascript - 如何在按钮单击时显示引导折叠 div?
- javascript - JavaScript 中的因式分解仅适用于递减递归,为什么?
- ios - 如何确定横向是否是常规的horizontalSizeClass?
- angular7 - 如何将响应映射到Angular 7中的对象
- r - R 的 HDBSCAN 因大型数据集而崩溃
- octave - 如何从八度音阶中选择图像的某些部分