MessageWidget constructor
MessageWidget({
- Key? key,
- required Message message,
- required MessageThemeData messageTheme,
- bool reverse = false,
- bool translateUserAvatar = true,
- ShapeBorder? shape,
- ShapeBorder? attachmentShape,
- BorderSide? borderSide,
- BorderSide? attachmentBorderSide,
- BorderRadiusGeometry? borderRadiusGeometry,
- BorderRadiusGeometry? attachmentBorderRadiusGeometry,
- void onMentionTap()?,
- void onMessageTap()?,
- bool showReactionPickerIndicator = false,
- DisplayWidget showUserAvatar = DisplayWidget.show,
- bool showSendingIndicator = true,
- bool showThreadReplyIndicator = false,
- bool showInChannelIndicator = false,
- void onReplyTap()?,
- void onThreadTap()?,
- bool showUsername = true,
- bool showTimestamp = true,
- bool showReactions = true,
- bool showDeleteMessage = true,
- bool showEditMessage = true,
- bool showReplyMessage = true,
- bool showThreadReplyMessage = true,
- bool showResendMessage = true,
- bool showCopyMessage = true,
- bool showFlagButton = true,
- bool showPinButton = true,
- bool showPinHighlight = true,
- void onUserAvatarTap()?,
- void onLinkTap()?,
- void onMessageActions()?,
- ShowMessageCallback? onShowMessage,
- Widget userAvatarBuilder()?,
- Widget editMessageInputBuilder()?,
- Widget textBuilder()?,
- Widget bottomRowBuilder()?,
- Widget deletedBottomRowBuilder()?,
- ValueChanged<
ReturnActionType> ? onReturnAction, - Map<
String, AttachmentBuilder> ? customAttachmentBuilders, - EdgeInsetsGeometry? padding,
- EdgeInsets textPadding = const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
- EdgeInsetsGeometry attachmentPadding = EdgeInsets.zero,
- @Deprecated(''' allRead is now deprecated and it will be removed in future releases. The MessageWidget now listens for read events on its own. ''') bool allRead = false,
- @Deprecated('''
readList is now deprecated and it will be removed in future releases.
The MessageWidget now listens for read events on its own.
''') List<
Read> ? readList, - OnQuotedMessageTap? onQuotedMessageTap,
- List<
MessageAction> customActions = const [], - void onAttachmentTap(
- Message message,
- Attachment attachment
- Widget usernameBuilder()?,
Implementation
MessageWidget({
Key? key,
required this.message,
required this.messageTheme,
this.reverse = false,
this.translateUserAvatar = true,
this.shape,
this.attachmentShape,
this.borderSide,
this.attachmentBorderSide,
this.borderRadiusGeometry,
this.attachmentBorderRadiusGeometry,
this.onMentionTap,
this.onMessageTap,
this.showReactionPickerIndicator = false,
this.showUserAvatar = DisplayWidget.show,
this.showSendingIndicator = true,
this.showThreadReplyIndicator = false,
this.showInChannelIndicator = false,
this.onReplyTap,
this.onThreadTap,
this.showUsername = true,
this.showTimestamp = true,
this.showReactions = true,
this.showDeleteMessage = true,
this.showEditMessage = true,
this.showReplyMessage = true,
this.showThreadReplyMessage = true,
this.showResendMessage = true,
this.showCopyMessage = true,
this.showFlagButton = true,
this.showPinButton = true,
this.showPinHighlight = true,
this.onUserAvatarTap,
this.onLinkTap,
this.onMessageActions,
this.onShowMessage,
this.userAvatarBuilder,
this.editMessageInputBuilder,
this.textBuilder,
this.bottomRowBuilder,
this.deletedBottomRowBuilder,
this.onReturnAction,
this.customAttachmentBuilders,
this.padding,
this.textPadding = const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
this.attachmentPadding = EdgeInsets.zero,
@Deprecated('''
allRead is now deprecated and it will be removed in future releases.
The MessageWidget now listens for read events on its own.
''') this.allRead = false,
@Deprecated('''
readList is now deprecated and it will be removed in future releases.
The MessageWidget now listens for read events on its own.
''') this.readList,
this.onQuotedMessageTap,
this.customActions = const [],
this.onAttachmentTap,
this.usernameBuilder,
}) : attachmentBuilders = {
'image': (context, message, attachments) {
final border = RoundedRectangleBorder(
borderRadius: attachmentBorderRadiusGeometry ?? BorderRadius.zero,
);
final mediaQueryData = MediaQuery.of(context);
if (attachments.length > 1) {
return Padding(
padding: attachmentPadding,
child: wrapAttachmentWidget(
context,
Material(
color: messageTheme.messageBackgroundColor,
child: ImageGroup(
size: Size(
mediaQueryData.size.width * 0.8,
mediaQueryData.size.height * 0.3,
),
images: attachments,
message: message,
messageTheme: messageTheme,
onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
onAttachmentTap: onAttachmentTap,
),
),
border,
reverse,
),
);
}
return wrapAttachmentWidget(
context,
ImageAttachment(
attachment: attachments[0],
message: message,
messageTheme: messageTheme,
size: Size(
mediaQueryData.size.width * 0.8,
mediaQueryData.size.height * 0.3,
),
onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
onAttachmentTap: onAttachmentTap != null
? () {
onAttachmentTap.call(message, attachments[0]);
}
: null,
),
border,
reverse,
);
},
'video': (context, message, attachments) {
final border = RoundedRectangleBorder(
borderRadius: attachmentBorderRadiusGeometry ?? BorderRadius.zero,
);
return wrapAttachmentWidget(
context,
Column(
children: attachments.map((attachment) {
final mediaQueryData = MediaQuery.of(context);
return VideoAttachment(
attachment: attachment,
messageTheme: messageTheme,
size: Size(
mediaQueryData.size.width * 0.8,
mediaQueryData.size.height * 0.3,
),
message: message,
onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
onAttachmentTap: onAttachmentTap != null
? () {
onAttachmentTap(message, attachment);
}
: null,
);
}).toList(),
),
border,
reverse,
);
},
'giphy': (context, message, attachments) {
final border = RoundedRectangleBorder(
borderRadius: attachmentBorderRadiusGeometry ?? BorderRadius.zero,
);
return wrapAttachmentWidget(
context,
Column(
children: attachments.map((attachment) {
final mediaQueryData = MediaQuery.of(context);
return GiphyAttachment(
attachment: attachment,
message: message,
size: Size(
mediaQueryData.size.width * 0.8,
mediaQueryData.size.height * 0.3,
),
onShowMessage: onShowMessage,
onReturnAction: onReturnAction,
onAttachmentTap: onAttachmentTap != null
? () {
onAttachmentTap(message, attachment);
}
: null,
);
}).toList(),
),
border,
reverse,
);
},
'file': (context, message, attachments) {
final border = RoundedRectangleBorder(
side: attachmentBorderSide ??
BorderSide(
color: StreamChatTheme.of(context).colorTheme.borders,
),
borderRadius: attachmentBorderRadiusGeometry ?? BorderRadius.zero,
);
return Column(
children: attachments
.map<Widget>((attachment) {
final mediaQueryData = MediaQuery.of(context);
return wrapAttachmentWidget(
context,
FileAttachment(
message: message,
attachment: attachment,
size: Size(
mediaQueryData.size.width * 0.8,
mediaQueryData.size.height * 0.3,
),
onAttachmentTap: onAttachmentTap != null
? () {
onAttachmentTap(message, attachment);
}
: null,
),
border,
reverse,
);
})
.insertBetween(SizedBox(
height: attachmentPadding.vertical / 2,
))
.toList(),
);
},
}..addAll(customAttachmentBuilders ?? {}),
super(key: key);