builder method

  1. @override
Widget builder(
  1. BuildContext ctx,
  2. bool showUserAvatar,
  3. bool showMessageStatus,
  4. bool showUsername,
  5. User loggedInUser,
  6. ChatTheme theme,
  7. AuthorDetailsLocation authorDetailsLocation,
)
override

Implementation

@override
Widget builder(
    BuildContext ctx,
    bool showUserAvatar,
    bool showMessageStatus,
    bool showUsername,
    User loggedInUser,
    ChatTheme theme,
    AuthorDetailsLocation authorDetailsLocation) {
  Widget returnValue = Column(
    children: [
      IntrinsicHeight(
        child: ConstrainedBox(
          constraints: BoxConstraints(
            maxHeight: MediaQuery.of(ctx).size.height * 0.5,
          ),
          child: ClipRRect(
            borderRadius: theme.imageBorderRadius ??
                const BorderRadius.only(
                  topLeft: Radius.circular(10),
                  topRight: Radius.circular(10),
                ),
            child: uri.toString().contains("http")
                ? CachedNetworkImage(
                    imageUrl: uri,
                    fit: BoxFit.contain,
                  )
                : Image.file(
                    File(uri),
                    fit: BoxFit.contain,
                  ),
          ),
        ),
      ),
      caption != null
          ? Padding(
              padding: theme.messagePadding,
              child: TextContainer(
                text: caption!,
                style: author.id == loggedInUser.id
                    ? theme.outwardMessageTextStyle
                    : theme.inwardMessageTextStyle,
                linkStyle: theme.urlTextStyle,
              ),
            )
          : Container(),
    ],
  );
  return MessageContainer(
    parentContext: ctx,
    message: this,
    theme: theme,
    showUserAvatar: showUserAvatar,
    showMessageStatus: showMessageStatus,
    showUsername: showUsername,
    user: loggedInUser,
    child: returnValue,
    detailsLocation: authorDetailsLocation,
  );
}