颤抖添加时间聊天消息

时间:2020-09-20 07:26:28

标签: firebase flutter datetime chat message

我必须在我的应用中创建聊天。问题在于,某人发送消息的时间未正确放置在聊天屏幕中,并且该数字不正确或太长。时间应该像这样(13:36)。有谁知道我怎样才能像whatsapp那样在消息下花费时间?这是我的ChatScreen here

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 Column(
      crossAxisAlignment: sendByMe ? CrossAxisAlignment.end : CrossAxisAlignment.start,
      children: <Widget>[
        Text( sendByMe ? time.toString() : time.toString(),style: sendByMe ?
        TextStyle(color: Colors.blue, fontWeight: FontWeight.bold, fontFamily: 'Orbitron', fontSize: 7.0,):
        TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontFamily: 'Orbitron', fontSize: 7.0,) ,
       ),
        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,),),
            ),
        ),
      ],
    );
  }

0 个答案:

没有答案