widgetChatBuildItem static method

Widget widgetChatBuildItem(
  1. BuildContext context,
  2. dynamic listMessage,
  3. String id,
  4. int index,
  5. DocumentSnapshot<Object?> document,
  6. String? peerAvatar,
)

Implementation

static Widget widgetChatBuildItem(BuildContext context, var listMessage,
    String id, int index, DocumentSnapshot document, String? peerAvatar) {
  if (document.get('idFrom') == id) {
    return Row(
      children: <Widget>[
        document.get('type') == 0
            ? chatText(document.get('content'), id, listMessage, index, true)
            : chatImage(context, id, listMessage, document.get('content'),
                index, true)
      ],
      mainAxisAlignment: MainAxisAlignment.end,
    );
  } else {
    return Container(
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              ChatData.isLastMessageLeft(listMessage, id, index)
                  ? Material(
                      child: widgetShowImages(peerAvatar!, 35),
                      borderRadius: BorderRadius.all(
                        Radius.circular(18.0),
                      ),
                      clipBehavior: Clip.hardEdge,
                    )
                  : Container(width: 35.0),
              document.get('type') == 0
                  ? chatText(
                      document.get('content'), id, listMessage, index, false)
                  : chatImage(context, id, listMessage,
                      document.get('content'), index, false)
            ],
          ),

          // Time
          ChatData.isLastMessageLeft(listMessage, id, index)
              ? Container(
                  child: Text(
                    DateFormat('dd MMM kk:mm').format(
                        DateTime.fromMillisecondsSinceEpoch(
                            int.parse(document.get('timestamp')))),
                    style: TextStyle(
                        color: greyColor,
                        fontSize: 12.0,
                        fontStyle: FontStyle.italic),
                  ),
                  margin: EdgeInsets.only(left: 50.0, top: 5.0, bottom: 5.0),
                )
              : Container()
        ],
        crossAxisAlignment: CrossAxisAlignment.start,
      ),
      margin: EdgeInsets.only(bottom: 10.0),
    );
  }
}