flutter - 如何使容器高度取决于文本颤动的长度
问题描述
我想知道,如何让容器高度取决于文本的长度并将其覆盖在容器中而不是在图 2 中如果我将文本设置得太长,文本会出现在容器上方,那么如何修复它
b-akused02 的消息:它很短,但仍然在高度:100,
关于 b-akused01 的消息:容器已过期
b-akused03 的消息:它很短,仍然在高度:100,
Widget _buildCommentItem({@required CommentDetail commentDetail}) {
return Container(
height: 100,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 20.0,
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
flex: 1,
child: Container(
height: 45, //height, //155,
width: 45, //width, //155,
decoration: BoxDecoration(
color: const Color(0xff7c94b6),
image: DecorationImage(
image: NetworkImage(
commentDetail.otherUserProfileImageUrl),
fit: BoxFit.cover,
),
borderRadius: BorderRadius.circular(12),
),
),
),
Expanded(
flex: 8,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Wrap(
// crossAxisAlignment: CrossAxisAlignment.start,
children: [
FittedBox(
fit: BoxFit.cover,
child: Text(
commentDetail.otherUsername,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Text(
commentDetail.comment,
style: TextStyle(
color: Colors.black,
),
),
],
),
),
),
],
),
),
),
SizedBox(
height: 20,
)
],
),
),
);
}
解决方案
将给定的容器包装在 Column 中,并从内部删除 height 参数。
推荐阅读
- javascript - GIT 从分支提交到一个
- android - 喷气背包组成。强制切换夜间/非夜间资源
- python - 我似乎无法找出在半圆上找到等距点的正确算法
- sql - 课程有很多学生,许多学生属于一门课程。如何找到特定学生所属的课程?
- c# - 为什么 Fma 代码的性能比 Avx 差?
- c# - 从 ASP.NET Core MVC 中的另一个视图访问一个控制器的变量
- serverless-framework - javascript 文件中的 console.log 打印两次。我可以阻止无服务器打印 JavaScript 文件的输出吗?
- flutter - 如何使用颤振接收 POST 请求的响应
- influxdb - 希望 InfluxDB 查询返回包括所有标签的结果
- flutter - 如何修改 TextButton 的大小,使其等于 Flutter 中子 Text 小部件的高度?