【发布时间】:2022-08-17 01:32:45
【问题描述】:
我想创建这个小部件。我试过的伪代码是这样的:
- 列
- 容器(我的小部件)
- 列
- 图像
- 堆栈
- 消息文本
- 已定位
- 状态文本
- 列
- 容器(我的小部件)
约束:
- 状态必须看起来像它保留在文本小部件中。但它不应该在上面。
- 文字和图片大小不固定!!!
问题:在没有大小的列内堆叠不起作用。因此,状态文本以居中显示在文本小部件下方。
return MessageBallon(
directory: message.direction,
childElement: Column(
children: [
message.hasMedia
? Container(
padding: EdgeInsets.only(bottom: height * .05),
child: CustomMedia(
src: message.media,
),
)
: const SizedBox(),
Stack(
children: [
Container(
padding: const EdgeInsets.only(
bottom: 13,
top: 18,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Container(
constraints: BoxConstraints(maxWidth: width * .53),
child: Text(
message.content,
style: TextStyles.normalTextBlack,
),
),
],
),
),
Positioned(
bottom: 0,
right: 0,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: 10),
child: Text(
message.messageDate,
style: TextStyles.detailText,
),
),
message.direction == SmsDirection.incoming
? Align(
alignment: Alignment.centerRight,
child: messageStatus,
)
: const SizedBox(),
],
),
)
],
)
],
),
);
-
你能包括你当前的 sn-p 吗?
-
你可以添加你的代码。因此,我们可以建议更改。
标签: flutter