【问题标题】:Stack inside column not working. What should I use instead?列内的堆栈不起作用。我应该改用什么?
【发布时间】: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


【解决方案1】:

只需使用带有 FloatingActionButton 的 Scaffold 来获取您的状态。

Rest Image 和 Text 可以在列内。

只有使用这些小部件,您才能实现如下所示。

【讨论】:

    猜你喜欢
    • 2015-11-18
    • 2021-04-05
    • 1970-01-01
    • 2021-08-12
    • 2019-04-07
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多