userListbuildItem static method

Widget userListbuildItem(
  1. BuildContext context,
  2. String currentUserId,
  3. DocumentSnapshot<Object?> document
)

Implementation

static Widget userListbuildItem(
    BuildContext context, String currentUserId, DocumentSnapshot document) {
  if (document.get('userId') == currentUserId) {
    return Container();
  } else {
    return Container(
      child: ElevatedButton(
          child: Row(
            children: <Widget>[
              Material(
                child: document.get('photoUrl') != null
                    ? widgetShowImages(document.get('photoUrl'), 50)
                    : Icon(
                        Icons.account_circle,
                        size: 50.0,
                        color: colorPrimaryDark,
                      ),
                borderRadius: BorderRadius.all(Radius.circular(25.0)),
                clipBehavior: Clip.hardEdge,
              ),
              Flexible(
                child: Container(
                  child: Column(
                    children: <Widget>[
                      Container(
                        child: Text(
                          'Nickname: ${document.get('nickname')}',
                          style: TextStyle(color: primaryColor),
                        ),
                        alignment: Alignment.centerLeft,
                        margin: EdgeInsets.fromLTRB(10.0, 0.0, 0.0, 5.0),
                      ),
                    ],
                  ),
                  margin: EdgeInsets.only(left: 20.0),
                ),
              ),
              ConstrainedBox(
                constraints: new BoxConstraints(
                  minHeight: 10.0,
                  minWidth: 10.0,
                  maxHeight: 30.0,
                  maxWidth: 30.0,
                ),
                child: new DecoratedBox(
                  decoration: new BoxDecoration(
                      color: document.get('online') == 'online'
                          ? Colors.greenAccent
                          : Colors.transparent),
                ),
              ),
            ],
          ),
          onPressed: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => Chat(
                          currentUserId: currentUserId,
                          peerId: document.id,
                          peerName: document.get('nickname'),
                          peerAvatar: document.get('photoUrl'),
                        )));
          },
          style: ElevatedButton.styleFrom(
              primary: viewBg,
              onPrimary: viewBg,
              padding: EdgeInsets.fromLTRB(25.0, 10.0, 25.0, 10.0))),
      margin: EdgeInsets.only(bottom: 10.0, left: 5.0, right: 5.0),
    );
  }
}