【问题标题】:Flutter Chat show time by send messageFlutter Chat 通过发送消息显示时间
【发布时间】:2020-09-19 18:44:00
【问题描述】:

在我的应用程序中,我创建了一个聊天。这是我的 messageTile。有谁知道我如何向这个容器添加另一个文本?因为这个文本应该是用户发送消息的时间。

class MessageTile extends StatelessWidget {
  final String message;
  final bool sendByMe;
  final int time;

  MessageTile({@required this.message, @required this.sendByMe, @required this.time});


  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
          top: 3,
          bottom: 3,
          left: sendByMe ? 0 : 24,
          right: sendByMe ? 24 : 0),
      alignment: sendByMe ? Alignment.centerRight : Alignment.centerLeft,
      child: Container(
        margin: sendByMe
            ? EdgeInsets.only(left: 30)
            : EdgeInsets.only(right: 30),
        padding: EdgeInsets.only(
            top: 17, bottom: 17, left: 20, right: 20),
        decoration: BoxDecoration(
            borderRadius: sendByMe ? BorderRadius.only(
                topLeft: Radius.circular(9),
                topRight: Radius.circular(9),
                bottomLeft: Radius.circular(9),
            ) :
            BorderRadius.only(
                topLeft: Radius.circular(9),
                topRight: Radius.circular(9),
                bottomRight: Radius.circular(9)),
           color: sendByMe ? Colors.blue : Colors.white
        ),
        child: Text(message,
                textAlign: TextAlign.start,
                style: TextStyle(
                color: Colors.black,
                fontWeight: FontWeight.bold,
                fontFamily: 'Orbitron',
                fontSize: 9.0,),),
        ),
    );
  }

【问题讨论】:

    标签: firebase flutter chat message


    【解决方案1】:

    根据您的布局包装成列或行。文本应该只是DateTime.now().toString()

    【讨论】: