firebase - 如何阻止堆栈中的两个小部件相互重叠?
问题描述
我有一个看起来像给定屏幕截图的聊天信使屏幕。如您所见,底部消息隐藏在文本输入区域的后面。消息是 listview ,使用 streambuilder 构建。我想要文本输入区域上方的消息。 https://i.stack.imgur.com/A82X2.png
return Scaffold(
appBar: AppBarMain(context),
body: Container(
child: Stack(
children: [
chatMessageList(),
Positioned(
bottom: 0,
child: Container(
color: Color(0x54ffffff),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 14, vertical: 20),
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Expanded(
child: TextField(
controller: messageController,
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
hintText: ' Message!...',
hintStyle: TextStyle(color: Colors.white54),
border: InputBorder.none),
),
),
InkWell(
onTap: () {
sendMessage();
},
child: Container(
padding: EdgeInsets.all(9),
height: 40,
width: 40,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0x36FFFFFF),
Color(0xFFFFFFFF)
],
),
borderRadius: BorderRadius.circular(40)),
child: Image.asset('assets/images/send.png')),
)
],
),
),
),
)
],
),
),
);
}
}
解决方案
你的结构应该是这样的
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: chatMessageList(),
),
MessageFieldWidget(),
],
)
这将确保您chatMessageList
将占用屏幕中的所有可用空间,并且您的消息字段将仅占用它需要的空间。您不需要使用定位或填充。
推荐阅读
- docker - 为什么 Docker 入口点脚本不在分离模式下执行?
- matrix - 在 ARKit 中将屏幕点取消投影到水平面
- java - 连接多个设备时如何将 Appium 服务器保持在其分配的 AppiumDriver 上
- android - 如何修复错误:不兼容的类型:tab1 无法转换为 Fragment?
- python-3.x - 将列表中的每个项目写入具有自动分配文件名的单独 txt 文件(python = 3.6)
- php - PHP 将变量封装为字符串
- android - androidx.mediarouter 抱怨 MediaBrowserCompat
- mongodb - 尝试连接mongodb单节点副本集超时异常
- postgresql - 优化名称重复数据删除查询
- java - 任何允许 Pivot 中的撇号 SQL 列别名的安全问题?