Firebase 颤振添加聊天时间消息

Firebase 颤振添加聊天时间消息,firebase,flutter,datetime,chat,message,Firebase,Flutter,Datetime,Chat,Message,我必须在我的应用程序中创建聊天。问题是有人发送信息的时间没有正确地放在聊天屏幕上,并且号码不正确或不长。时间应该是这样的(13:36)。有人知道我如何像whatsapp那样把时间放在信息下面吗?这是我的聊天屏幕 class MessageTile扩展了无状态小部件{ 最终字符串消息; 最后的布尔森德比姆; 最终整数时间; MessageTile({@required this.message、@required this.sendByMe、@required this.time}); @凌驾 小

我必须在我的应用程序中创建聊天。问题是有人发送信息的时间没有正确地放在聊天屏幕上,并且号码不正确或不长。时间应该是这样的(13:36)。有人知道我如何像whatsapp那样把时间放在信息下面吗?这是我的聊天屏幕

class MessageTile扩展了无状态小部件{
最终字符串消息;
最后的布尔森德比姆;
最终整数时间;
MessageTile({@required this.message、@required this.sendByMe、@required this.time});
@凌驾
小部件构建(构建上下文){
返回列(
crossAxisAlignment:sendByMe?crossAxisAlignment.end:crossAxisAlignment.start,
儿童:[
文本(sendByMe?time.toString():time.toString(),样式:sendByMe?
TextStyle(颜色:Colors.blue,fontWeight:fontWeight.bold,fontFamily:'Orbitron',fontSize:7.0,):
TextStyle(颜色:Colors.white,fontWeight:fontWeight.bold,fontFamily:'Orbitron',fontSize:7.0,),
),
容器(
填充:仅限边缘设置(
排名:3,
底部:3,
左:sendByMe?0:24,
右:sendByMe?24:0),
对齐:sendByMe?对齐。中间右侧:对齐。中间左侧,
子:容器(
页边空白:sendByMe
?仅限边缘设置(左:30)
:仅限边缘设置(右:30),
填充:仅限边缘设置(
顶部:17,底部:17,左侧:20,右侧:20),
装饰:盒子装饰(
borderRadius:sendByMe?仅限borderRadius(
左上:半径。圆形(9),
右上角:半径。圆形(9),
左下角:半径。圆形(9),
) :
仅限边界半径(
左上:半径。圆形(9),
右上角:半径。圆形(9),
右下角:半径。圆形(9)),
颜色:sendByMe?颜色。蓝色:颜色。白色
),
子:文本(消息,
textAlign:textAlign.start,
样式:TextStyle(
颜色:颜色,黑色,
fontWeight:fontWeight.bold,
Fontron家族:“轨道飞行器”,
字体大小:9.0,),),
),
),
],
);
}

您使用int datatype来存储时间数据,而不是DateTime,有什么具体原因吗?没有,实际上只是为了让消息按时间排序,所以从上到下,将时间存储为DateTime或字符串更合适。您可以使用compareTo()方法对它们进行排序。例如,如何进行排序?您可以展示示例吗
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,),),
            ),
        ),
      ],
    );
  }